Generate stable IDs for labels and ARIA relationships.
Section: Context and Ref Hooks
useId for stable accessible IDs
tsx
tsx
const id = useId();
return <><label htmlFor={id}>Email</label><input id={id} /></>;Explanation
Useful for accessibility when components need unique IDs that work consistently with server rendering.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Context and Ref Hooks
useRef mutable container
Persist mutable values between renders without re-rendering.
useImperativeHandle custom ref API
Expose a controlled imperative API to a parent ref.