Skip to main content
useId generates a unique ID that is stable across server and client renders. This is useful for accessibility attributes like aria-describedby that require matching IDs between elements.

Signature

Parameters

This hook takes no parameters.

Returns

Returns a unique string ID that:
  • Is stable across renders of the same component instance
  • Is unique within the application
  • Is consistent between server-side and client-side rendering
  • Follows the format P{rootId}-{incrementId}

Basic Usage

Accessibility with ARIA

Radio Button Group

Combobox with Listbox

Accordion with Multiple Panels

Dialog with Description

Tab Panel

useId is especially important for server-side rendering (SSR). It ensures that IDs match between the server-rendered HTML and the client-side hydrated version, preventing hydration mismatches.
Don’t use useId to generate keys for list items. Keys should be based on your data, not generated IDs.
Each call to useId generates a new unique ID. If you need multiple related IDs, call useId once and derive the other IDs by appending suffixes like ${id}-label, ${id}-input, etc.