useId in React

From the React Hooks cheat sheet · Additional Hooks · verified Nov 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
⚠️ Never use it for list keys - derive keys from your data
📌 Use identifierPrefix in createRoot when a page has several React roots

Continue with React Hooks

Save the full cheat sheet or work through every related task.

More React tasks

Back to the full React Hooks cheat sheet