Shadcn.io is not affiliated with official shadcn/ui
React useMap Hook
React useMap hook for Map state with set, setAll, remove, and reset actions. Immutable updates, TypeScript generics. SSR safe.
Manage Map state in React with convenient CRUD helpers. useMap returns a Map instance plus set, setAll, remove, and reset actions. All updates create new Map instances for React's immutability requirements. Initialize with a Map or array of key-value tuples. Full TypeScript generics for key and value types. The returned Map has all read methods (get, has, keys, values, entries, forEach, size). Perfect for caching, lookup tables, form field tracking, or any keyed data. SSR safe—just a useState wrapper. Works with Next.js App Router and any React framework.
React useMap Hook preview
Installation
Related Components
React useSet Hook
Set state with add/remove/toggle
React useLocalStorage Hook
Persist state to localStorage
React useBoolean Hook
Boolean state with toggle helpers
React useCounter Hook
Counter with increment/decrement
React useToggle Hook
Toggle between custom values
React useStep Hook
Multi-step wizard state
FAQ
Was this page helpful?
Sign in to leave feedback.