useId in React

From the React Hooks cheat sheet · Additional Hooks · verified Jul 2026

useId

Generate unique IDs

javascript
// Generate unique ID for accessibility
const id = useId()

return (
  <>
    <label htmlFor={id}>Name:</label>
    <input id={id} />
  </>
)

// Multiple IDs
const id = useId()
const emailId = `${id}-email`
const passwordId = `${id}-password`
✅ SSR-safe unique IDs
💡 Perfect for form labels and ARIA attributes

More React tasks

Back to the full React Hooks cheat sheet