Use Lanyard API easily in your React app!
Get support Β»
Report Bug
Β·
Request Feature
Β·
What Is Lanyard
- Using yarn:
yarn add react-use-phplanyard
- Using npm:
npm i react-use-phplanyard
Using without websocket:
import { useLanyard } from "react-use-phplanyard";
function App() {
const lanyard = useLanyard({
userId: "697757845063729194",
});
return (
<pre>{!lanyard.isValidating && JSON.stringify(lanyard, null, 4)}</pre>
);
}
export default App;
Using with websocket:
import { useLanyard } from "react-use-phplanyard";
function App() {
const { loading, status /*, websocket */ } = useLanyard({
userId: "697757845063729194",
socket: true,
});
return <pre>{!loading && JSON.stringify(status, null, 4)}</pre>;
}
export default App;
You can create/delete KV pairs using this package.
import { set, del } from "react-use-phplanyard";
// 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: "phpxcoder.rest", // 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: "phpxcoder.rest", // if you are using self-hosted api, not required by default
});
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 useLanyard
hook. See Lanyard self-hosting guide for more information.
Using without websocket:
import { useLanyard } from "react-use-phplanyard";
function App() {
const lanyard = useLanyard({
userId: "697757845063729194",
apiUrl: "phpxcoder.rest",
});
return (
<pre>{!lanyard.isValidating && JSON.stringify(lanyard, null, 4)}</pre>
);
}
export default App;
Using with websocket:
import { useLanyard } from "react-use-phplanyard";
function App() {
const { loading, status /*, websocket */ } = useLanyard({
userId: "697757845063729194",
socket: true,
apiUrl: "phpxcoder.rest",
});
return <pre>{!loading && JSON.stringify(status, null, 4)}</pre>;
}
export default App;
Copyright Β© 2021 BarΔ±Ε DEMΔ°RCΔ°.
Distributed under the GPL-3.0 License. See LICENSE
for more information.
Feel free to use GitHub's features.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/my-feature
) - Run prettier and eslint (
npm run format && npm run lint
) - Commit your Changes (
git commit -m 'my awesome feature my-feature'
) - Push to the Branch (
git push origin feature/my-feature
) - Open a Pull Request
Give a βοΈ if this project helped you!
- Mail: php@phpxcoder.in
- Discord: https://discord.gg/BjEJFwh
- Instagram: https://instagram.com/phpxcoder/
- Phineas - Creator of Lanyard API
- Eggsy - Creator of vue-lanyard