0.3.1 • Published 5 months ago

react-use-lanyard v0.3.1

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
5 months ago

stars license supportServer forks issues

📦 Installation

  • Using yarn: yarn add react-use-lanyard
  • Using npm: npm i react-use-lanyard

🤓 Usage

Using without websocket:

import { useLanyard } from "react-use-lanyard";

function App() {
	const lanyard = useLanyard({
		userId: "952574663916154960",
	});

	return (
		<pre>{!lanyard.isValidating && JSON.stringify(lanyard, null, 4)}</pre>
	);
}

export default App;

Using with websocket:

import { useLanyard } from "react-use-lanyard";

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

	return <pre>{!loading && JSON.stringify(status, null, 4)}</pre>;
}

export default App;

🔐 KV Support

You can create/delete KV pairs using this package.

import { set, del } from "react-use-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 useLanyard hook. See Lanyard self-hosting guide for more information.

Using without websocket:

import { useLanyard } from "react-use-lanyard";

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

	return (
		<pre>{!lanyard.isValidating && JSON.stringify(lanyard, null, 4)}</pre>
	);
}

export default App;

Using with websocket:

import { useLanyard } from "react-use-lanyard";

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

	return <pre>{!loading && JSON.stringify(status, null, 4)}</pre>;
}

export default App;

📄 License

Copyright © 2021 Barış DEMİRCİ.

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!

📞 Contact

✨ Special Thanks

0.3.1

5 months ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

3 years ago

0.1.0-alpha.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.6-alpha.8

3 years ago

0.0.6-alpha.7

3 years ago

0.0.6-alpha.6

3 years ago

0.0.6-alpha.5

3 years ago

0.0.6-alpha.4

3 years ago

0.0.6-alpha.3

3 years ago

0.0.6-alpha.2

3 years ago

0.0.6-alpha.1

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago