useId

The React hook that generates a unique ID string that is stable across renders and matches between server and browser.

In more detail

Accessible components need IDs to link elements, for example aria-controls on a tab pointing at its panel's id. useId makes those IDs unique even when a component appears several times on a page.

Example

const id = useId(); <input id={`${id}-in`} aria-describedby={`${id}-hint`} />

Related terms

Taught in

References