{"id":15639990,"url":"https://github.com/alii/use-lanyard","last_synced_at":"2025-04-13T05:36:28.153Z","repository":{"id":43746393,"uuid":"347369947","full_name":"alii/use-lanyard","owner":"alii","description":"React hook for Lanyard for tracking your Discord presence.","archived":false,"fork":false,"pushed_at":"2024-09-05T17:00:13.000Z","size":616,"stargazers_count":84,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-26T22:12:06.745Z","etag":null,"topics":["discord","hook","presence","react"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-lanyard","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-13T12:52:38.000Z","updated_at":"2025-01-08T14:30:35.000Z","dependencies_parsed_at":"2024-06-18T19:59:42.732Z","dependency_job_id":"6f802aab-2a1f-4766-bbca-f6caaaa7c6aa","html_url":"https://github.com/alii/use-lanyard","commit_stats":{"total_commits":65,"total_committers":9,"mean_commits":7.222222222222222,"dds":"0.46153846153846156","last_synced_commit":"32e9364a4b414a70e57aa88f1e94cf08812218c1"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fuse-lanyard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fuse-lanyard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fuse-lanyard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alii%2Fuse-lanyard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alii","download_url":"https://codeload.github.com/alii/use-lanyard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670508,"owners_count":21142897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","hook","presence","react"],"created_at":"2024-10-03T11:29:38.040Z","updated_at":"2025-04-13T05:36:28.131Z","avatar_url":"https://github.com/alii.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `use-lanyard`\n\nReact hook for [lanyard](https://github.com/Phineas/lanyard), an easy way to track your Discord presence through REST or WebSocket.\n\n### Features\n\n- Easy to use\n- Zero dependencies\n- TypeScript support\n- WebSocket support\n- Deduplicates network requests\n\n```tsx\nimport {useLanyard} from 'use-lanyard';\n\nconst DISCORD_ID = '268798547439255572';\n\nexport function Lanyard() {\n\tconst {data} = useLanyard(DISCORD_ID);\n\n\treturn \u003c\u003e...\u003c/\u003e;\n}\n```\n\n### Server-side rendering / initial data\n\nYou can also provide initial data to the hook, which will be used until the client is hydrated/able to fetch the latest data.\n\n```tsx\nconst {data} = useLanyard(DISCORD_ID, {\n\tinitialData: myInitialDataFromTheServer,\n});\n\n// Also works with the WebSocket hook\nconst data = useLanyardWS(DISCORD_ID, {\n\tinitialData: myInitialDataFromTheServer,\n});\n```\n\n### Socket\n\nThere is also a hook for using the WebSocket that Lanyard provides, here's an example:\n\n```tsx\nimport {useLanyardWS} from 'use-lanyard';\n\nconst DISCORD_ID = '268798547439255572';\n\nexport function Lanyard() {\n\tconst data = useLanyardWS(DISCORD_ID);\n\n\treturn \u003c\u003e...\u003c/\u003e;\n}\n```\n\n### Advanced usage\n\nIf you need access to the underlying response types in TypeScript, you can import them as follows.\n\n```ts\n// See src/types.ts for all types\nimport type {Data, Activity, LanyardResponse} from 'use-lanyard';\n```\n\nYou can also customize the API endpoint that is used, if you wanted to self-host Lanyard.\n\n```ts\nexport function Lanyard() {\n\tconst {data} = useLanyard(DISCORD_ID, {\n\t\tapi: {\n\t\t\thostname: 'my-lanyard.app',\n\n\t\t\t// Tell the hook to use https/wss or http/ws\n\t\t\tsecure: true,\n\t\t},\n\t});\n\n\treturn \u003c\u003e...\u003c/\u003e;\n}\n```\n\n## Acknowledgements\n\n- [Phineas Walton](https://github.com/Phineas/) – Author of lanyard\n- [Alistair Smith](https://github.com/alii/) – Author of this library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falii%2Fuse-lanyard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falii%2Fuse-lanyard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falii%2Fuse-lanyard/lists"}