pkgdocs/compare/immer vs jotai

Comparing

npm

immer

Create your next immutable state by mutating the current one

41.7M/ wk
v11.1.4
vs
npm

jotai

Primitive and flexible state management for React based on atomic state units.

900K/ wk
v2.9.3
Metricimmerjotai
Ecosystemnpmnpm
DifficultyBeginnerBeginner
Weekly downloads41.7M↑900K
Latest versionv11.1.4v2.9.3
Recipes12↑

Tags

immer only

immutablereduxmutationsmutablecopy-on-writeimmutablesreducer

Shared

statereacttypescript

jotai only

atomshooks

When to use each

immer

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.

jotai

React apps needing shared state without prop drilling, derived/computed state that updates automatically, fine-grained re-render control, per-route or per-feature isolated state.

When to skip each

immer

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().

jotai

Non-React environments (Jotai is React-only). Complex state machines (use XState). Apps already committed to Redux with large middleware ecosystems.

Sample recipes

immer

  • Install immer

jotai

  • Replace useState with a shared atom
  • Derived atom for computed state