Comparing
Create your next immutable state by mutating the current one
🐻 Bear necessities for state management in React
| Metric | immer | zustand |
|---|---|---|
| Ecosystem | npm | npm |
| Difficulty | Beginner ✓ | Intermediate |
| Weekly downloads | 41.7M↑ | 30.7M |
| Latest version | v11.1.4 | v5.0.12 |
| Recipes | 1 | 7↑ |
immer only
Shared
zustand only
Use Immer whenever you have deeply nested state updates that are painful to write immutably: Redux reducers, Zustand's set function, or React useState with complex objects. It's built into Redux Toolkit's createSlice, so you're probably already using it.
Use Zustand for global UI state that multiple components need to read and write: auth status, theme preferences, shopping cart, modal state, or any data too complex for prop drilling but not complex enough to justify Redux.
For flat, simple state (a counter, a boolean toggle), immer's overhead isn't worth it — just spread the object. Immer also has edge cases with classes, Maps, and Sets that require using enableMapSet() and enableAllPlugins().
Zustand is not designed for server state — use React Query for that. For very large applications with complex state machines or time-travel debugging requirements, Redux Toolkit's tooling is more mature.
immer
zustand
+3 more