Skip to content

dfrnoch/solid-lanyard

Repository files navigation

Solid Create Lanyard

Solid.js port of react-use-lanyard


Use Lanyard API easily in your Solid app!
Report Bug · Request Feature · What Is Lanyard

📦 Installation

  • Using yarn: yarn add solid-create-lanyard
  • Using npm: npm i solid-create-lanyard

🤓 Usage

Using without websocket:

import { createLanyard } from "solid-create-lanyard";

function App() {
  const { latest, loading } = createLanyard({
    userId: "952574663916154960",
  });

  return (
    <Show when={!loading}>
      <pre>{JSON.stringify(latest.data, null, 4)}</pre>
    </Show>
  );
}

export default App;

Using with websocket:

import { createLanyard } from "solid-create-lanyard";

function App() {
  const { loading, status /*, websocket */ } = createLanyard({
    userId: "952574663916154960",
    socket: true,
  });

  return (
    <Show when={!loading()}>
      <div>status: {JSON.stringify(status)}</div>
    </Show>
  );
}

export default App;

🔐 KV Support

You can create/delete KV pairs using this package.

import { del, set } from "solid-create-lanyard";

// Set KV pair
await set({
  apiKey: "your_api_key", // get it using .apikey command on lanyard bot
  userId: "your_user_id",
  key: "test_key",
  value: "test value",
  // apiUrl: "lanyard.338.rocks", // if you are using self-hosted api, not required by default
});

// Delete KV pair
await del({
  apiKey: "your_api_key",
  userId: "your_user_id",
  key: "test_key",
  // apiUrl: "lanyard.338.rocks", // if you are using self-hosted api, not required by default
});

🤞 Using Self-Hosted API

You can use this package to connect to your own self-hosted Lanyard API. To do this, you need to pass the apiUrl option to the createLanyard hook. See Lanyard self-hosting guide for more information.

Using without websocket:

import { createLanyard } from "solid-create-lanyard";

function App() {
  const { latest, loading } = createLanyard({
    userId: "952574663916154960",
    apiUrl: "lanyard.338.rocks",
  });

  return (
    <Show when={!loading}>
      <pre>{JSON.stringify(latest.data, null, 4)}</pre>
    </Show>
  );
}

export default App;

Using with websocket:

import { createLanyard } from "solid-create-lanyard";

function App() {
  const { loading, status /*, websocket */ } = createLanyard({
    userId: "952574663916154960",
    socket: true,
    apiUrl: "lanyard.338.rocks",
  });

  return (
    <Show when={!loading()}>
      <div>status: {JSON.stringify(status)}</div>
    </Show>
  );
}

export default App;

📄 License

Distributed under the GPL-3.0 License. See LICENSE for more information.

🧦 Contributing

Feel free to use GitHub's features.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Run prettier and eslint (npm run format && npm run lint)
  4. Commit your Changes (git commit -m 'my awesome feature my-feature')
  5. Push to the Branch (git push origin feature/my-feature)
  6. Open a Pull Request

🔥 Show your support

Give a ⭐️ if this project helped you!

✨ Special Thanks

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published