useId for Accessible Unique IDs
Learn how useId generates stable, unique identifiers for accessibility attributes without mismatching between server and client.
useId() returns a unique string identifier that's stable across a component instance's lifetime, intended primarily for linking form elements to their labels and ARIA attributes (htmlFor, aria-describedby, aria-labelledby). It was added in React 18 specifically to solve an SSR-hydration problem that ad-hoc ID generation approaches ran into.
useId is like assigning permanent seat numbers printed on tickets before the show even starts, rather than having ushers hand out numbers as people walk in — everyone (server and client) agrees on the same seat assignment in advance, so there's no mismatch when people take their seats.