{"id":13450534,"url":"https://github.com/Yaska/react-use-id-hook","last_synced_at":"2025-03-23T16:31:35.483Z","repository":{"id":42959961,"uuid":"198402122","full_name":"Yaska/react-use-id-hook","owner":"Yaska","description":"Hook to create SSR-safe consistent unique id strings","archived":false,"fork":false,"pushed_at":"2023-01-06T02:21:56.000Z","size":2522,"stargazers_count":4,"open_issues_count":9,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-25T04:42:27.615Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Yaska.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}},"created_at":"2019-07-23T09:52:08.000Z","updated_at":"2022-01-26T17:15:21.000Z","dependencies_parsed_at":"2023-02-05T02:45:48.497Z","dependency_job_id":null,"html_url":"https://github.com/Yaska/react-use-id-hook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yaska%2Freact-use-id-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yaska%2Freact-use-id-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yaska%2Freact-use-id-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yaska%2Freact-use-id-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yaska","download_url":"https://codeload.github.com/Yaska/react-use-id-hook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809845,"owners_count":20351407,"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":[],"created_at":"2024-07-31T07:00:35.777Z","updated_at":"2025-03-23T16:31:35.149Z","avatar_url":"https://github.com/Yaska.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# react-use-id-hook\n\nThis is a tiny hook to create consisent id strings while rendering React, both when doing SSR and normally.\n\nThis is useful for creating unique `id` attributes for DOM elements.\n\n## API\n\n### `\u003cIdProvider [prefix=\"id-\"] /\u003e`\n\nThis provider provides the id state. Your app needs to be wrapped with it.\n\n### `useId()`\n\nThis hook returns a unique id that remains consistent on re-render\n\n### `useGetId()`\n\nThis hook returns a function that returns unique ids. To use it, the same rule applies as for hooks:\n\n\u003e always call it in the same order, without control flow\n\n## Installation\n\n1. Install the `react-use-id-hook` NPM package with your favorite package manager.\n2. Wrap your top-level component with `\u003cIdProvider\u003e`\n3. In your components, use `useId()` or `useGetId()` as appropriate.\n\n## Example\n\n[See the full example](https://github.com/Yaska/react-use-id-hook/blob/master/example/index.tsx).\n\n```js\nconst CheckBox = ({value, onChange}) =\u003e {\n\tconst id = useId()\n\n\treturn (\n\t\t\u003c\u003e\n\t\t\t\u003cinput\n\t\t\t\tid={id}\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\tchecked={value}\n\t\t\t\tonChange={(ev) =\u003e onChange(ev.target.checked)}\n\t\t\t/\u003e\n\t\t\t\u003clabel htmlFor={id}\u003eClick me\u003c/label\u003e\n\t\t\u003c/\u003e\n\t)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYaska%2Freact-use-id-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYaska%2Freact-use-id-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYaska%2Freact-use-id-hook/lists"}