← All notes

React useId: unique IDs for accessibility attributes

Answer: useId is a Hook that generates unique IDs you can pass to accessibility attributes. useId does not take any parameters. You cannot call it inside loops or conditions. useId should not be used to generate cache keys.

Examples

import { useId } from 'react';

function Field() {
  const id = useId();
  return <><label htmlFor={id}>Name</label><input id={id} /></>;
}

Notes

Call useId at the top level of your component. If you need IDs in a loop, extract a new component and move the hook into it. The ID is stable when a component is mounted, but it may change during rendering. Generate cache keys from your data instead.

Reference list

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: React docs, useId; reactjs/react.dev, useId.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: React docs, useId; reactjs/react.dev, useId.md. CC-BY-4.0 (https://raw.githubusercontent.com/reactjs/react.dev/main/LICENSE-DOCS.md). Copyright Meta Platforms, Inc. and affiliates.

Cite this

Permanent ID: iil:note:1wsv06e0

iinventedlight. 2026. "React useId: unique IDs for accessibility attributes." iinventedlight Library, iil:note:1wsv06e0, version of 2026-11-18. https://iinventedlight.com/library/notes/react-useid/. License: CC-BY-4.0.

@misc{iil_note_1wsv06e0,
  author = {{iinventedlight}},
  title = {{React useId: unique IDs for accessibility attributes}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/react-useid/},
  note = {Permanent ID iil:note:1wsv06e0. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/react-useid.md.