{"id":25692293,"url":"https://github.com/calico32/solid-use-lanyard","last_synced_at":"2026-05-09T07:40:15.166Z","repository":{"id":115909095,"uuid":"530840782","full_name":"calico32/solid-use-lanyard","owner":"calico32","description":"SolidJS wrapper for the Lanyard API","archived":false,"fork":false,"pushed_at":"2022-08-31T00:21:05.000Z","size":1224,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-03T23:51:18.549Z","etag":null,"topics":["discord","javascript","lanyard","solid-js","typescript","websocket"],"latest_commit_sha":null,"homepage":"","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/calico32.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-08-30T21:41:58.000Z","updated_at":"2022-08-30T21:44:01.000Z","dependencies_parsed_at":"2023-09-24T03:46:58.254Z","dependency_job_id":null,"html_url":"https://github.com/calico32/solid-use-lanyard","commit_stats":null,"previous_names":["wiisportsresort/solid-use-lanyard"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/calico32/solid-use-lanyard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calico32%2Fsolid-use-lanyard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calico32%2Fsolid-use-lanyard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calico32%2Fsolid-use-lanyard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calico32%2Fsolid-use-lanyard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calico32","download_url":"https://codeload.github.com/calico32/solid-use-lanyard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calico32%2Fsolid-use-lanyard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32811656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","javascript","lanyard","solid-js","typescript","websocket"],"created_at":"2025-02-24T23:08:45.689Z","updated_at":"2026-05-09T07:40:15.150Z","avatar_url":"https://github.com/calico32.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `solid-use-lanyard`\n\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/solid-use-lanyard\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/solid-use-lanyard\"\u003e\n    \u003cimg src=\"https://img.shields.io/bundlephobia/min/solid-use-lanyard\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\nA SolidJS wrapper around the [Lanyard](https://github.com/Phineas/lanyard) API. Supports both REST and WebSocket modes, and includes full support for TypeScript.\n\n\n\n## Installation\n\n```bash\nyarn add solid-use-lanyard\nnpm install solid-use-lanyard\n```\n\n## Usage\n\n```jsx\nimport useLanyard, { appAssetUrl, userAvatarUrl } from 'solid-use-lanyard'\n\nconst Component = () =\u003e {\n  // Default: WebSocket API\n  const presence = useLanyard('user_id')\n  // presence: () =\u003e Presence | undefined\n\n  // Advanced properties\n  const { presence, close, closed } = useLanyard('user_id')\n  // equivalent to:\n  const { presence, close, closed } = useLanyard({ type: 'socket', id: 'user_id' })\n  // presence: () =\u003e Presence | undefined\n  // close: () =\u003e void\n  // closed: () =\u003e boolean\n\n  // Multiple users\n  const { presence, close, closed, latestUpdate } = useLanyard({ type: 'socket', ids: ['user_id1', 'user_id2'] })\n  // All users\n  const { presence, close, closed, latestUpdate } = useLanyard({ type: 'socket', all: true })\n  // presence: () =\u003e { [id: string]: Presence }\n  // close: () =\u003e void\n  // closed: () =\u003e boolean\n  // latestUpdate: () =\u003e Presence \u0026 { user_id: string }\n\n  // The WebSocket client will automatically reconnect if the connection is lost\n\n\n  // REST API (single API call only)\n  const presence = useLanyard({ type: 'rest', id: 'user_id' })\n  // presence: () =\u003e Presence | undefined\n\n  // REST with auto-refresh\n  const presence = useLanyard({ type: 'rest', id: 'user_id', refreshInterval: 1000 /* ms */ })\n  // presence: () =\u003e Presence | undefined\n  \n  // Advanced properties\n  const { presence, cancel } = useLanyard({ type: 'rest', id: 'user_id', refreshInterval: 1000 /* ms */ })\n  // presence: () =\u003e Presence | undefined\n  // cancel: () =\u003e void\n\n\n  // Helpers\n  const avatar = userAvatarUrl('user_id', 'webp' | 'png' | 'jpg' | 'jpeg' | 'gif') // default: 'webp'\n  // avatar: string\n\n  const asset = appAssetUrl(activity.application_id, activity.assets?.large_image, 'webp' | 'png' | 'jpg' | 'jpeg' | 'gif') // default: 'webp'\n  // asset: string\n\n  // (easily make these reactive by wrapping them in a function)\n\n\n  // Example single-user component:\n  return presence() \u0026\u0026 (\n    \u003cFor each={presence().activities}\u003e\n      {(activity) =\u003e (\n        \u003cdiv\u003e\n          \u003cimg src={appAssetUrl(activity.application_id, activity.assets?.large_image)} /\u003e\n          \u003ch1\u003e{activity.name}\u003c/h1\u003e\n          \u003cp\u003e{activity.details}\u003c/p\u003e\n          \u003cp\u003e{activity.state}\u003c/p\u003e\n        \u003c/div\u003e\n      )}\n    \u003c/For\u003e\n  )\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalico32%2Fsolid-use-lanyard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalico32%2Fsolid-use-lanyard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalico32%2Fsolid-use-lanyard/lists"}