All topics
Stateadvanced

Jotai and Atomic State Management

Learn the atomic state model, where state is composed from small independent units rather than one large store or tree.

Jotai takes an 'atomic' approach to state management, inspired partly by Recoil: instead of one large store object or a single Context value, you define many small, independent units of state called atoms, each created with atom(initialValue). Components subscribe to exactly the atoms they need via useAtom, and only those specific atoms' subscribers re-render when that atom's value changes.

Atomic state is like a spreadsheet: each cell (atom) holds its own value or formula referencing other cells (derived atoms), and changing one cell only recalculates and re-displays the cells that actually depend on it, rather than re-rendering the entire spreadsheet from scratch on any single edit.

Key Concepts

1
This bottom-up model avoids both the Context API's broad re-render problem (since there's no single large value object to invalidate consumers) and some of Redux's ceremony (no actions or reducers required for simple atoms), while still allowing composition: derived atoms can be computed from other atoms (atom(get => get(atomA) + get(atomB))), forming a dependency graph that Jotai tracks automatically, re-computing derived atoms only when their specific dependencies change.
derived atomsatom(get => get(atomA) + get(atomB))
2
Because atoms are just values (often created inline with atom()), they can be defined close to where they're used, support code-splitting naturally (an atom only 'exists' meaningfully once a component subscribes to it), and can be scoped to specific parts of the tree with Provider boundaries if isolated instances are needed (e.g., multiple independent instances of the same form component).
atom()
3
Interviewers exploring newer state paradigms may ask candidates to contrast atomic state models with the more traditional 'single store, subscribe to slices' model of Redux/Zustand — a thoughtful answer highlights the fine-grained dependency tracking and natural composability of derived atoms as the key differentiator.