# Client State Libraries: Zustand, Redux Toolkit and Jotai

> Use a store library when global client state outgrows context: Zustand for simplicity, Redux Toolkit for large teams, Jotai for atoms. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/state-libraries
Last updated: 2026-11-28

Use a store library when global client state outgrows context: Zustand for simplicity, Redux Toolkit for large teams, Jotai for atoms.

Intermediate · about 5 hours · difficulty 3/5

Learn first: [State Management Principles](https://www.internhack.in/roadmaps/tracks/frontend/state-management)

Once you know what is truly global client state, a small library can manage it with less boilerplate and better performance than context.

### Zustand (our default)

A tiny store created with a hook: `const useCart = create((set) => ({ items: [], add: (i) => set((s) => ({ items: [...s.items, i] })) }))`. Components subscribe with **selectors** (`useCart(s => s.items.length)`) and re-render only when the selected slice changes. Middleware adds persistence (`persist`) and devtools. Minimal API, no providers.

### Redux Toolkit

The modern, official way to write Redux. `createSlice` generates reducers and actions (with Immer letting you write "mutating" code safely), `configureStore` sets up devtools, and **RTK Query** handles server data. Redux shines in large apps and teams that value strict patterns, time-travel debugging and a single, predictable event log. Many existing codebases use it, so you should be able to read it.

### Jotai

State as **atoms**: small independent pieces (`const countAtom = atom(0)`) combined into derived atoms. It fits apps with lots of fine-grained, interdependent state such as editors and canvases.

### Others you may meet

MobX (observable, mutable style), Valtio (proxy state) and XState (state machines for complex flows, optional but powerful).

### Pitfalls

Selecting the whole store (`useStore()`) so every change re-renders everything; putting server data in these stores instead of a server-state library; creating one giant store for unrelated concerns.

### Good enough to move on

You can implement a persisted cart in Zustand with selectors, read and modify a Redux Toolkit slice in an existing codebase, and explain when you would reach for each tool.

## Key concepts

- **Zustand stores and selectors**
- **Zustand persist and devtools middleware**
- **Redux Toolkit createSlice and configureStore**
- **Redux DevTools**
- **Jotai atoms and derived atoms**
- **Selector-based re-render control**
- **State machines with XState**

## Mini project

Build a shopping cart with Zustand (persisted to localStorage, selector-based badge count), then re-implement the same slice with Redux Toolkit and compare the amount of code and the devtools experience.

## Check yourself

Why does \`const store = useCartStore()\` re-render a component more often than \`useCartStore(s => s.count)\`?

## Free resources

- [Zustand documentation](https://zustand.docs.pmnd.rs/) (Zustand)
- [Redux Toolkit](https://redux-toolkit.js.org/) (Redux)
- [Jotai](https://jotai.org/) (Jotai)

Previous: [State Management Principles](https://www.internhack.in/roadmaps/tracks/frontend/state-management) · Next: [Server State with TanStack Query](https://www.internhack.in/roadmaps/tracks/frontend/server-state)

## More in Routing, State and Data

- [Client-Side Routing](https://www.internhack.in/roadmaps/tracks/frontend/client-routing)
- [State Management Principles](https://www.internhack.in/roadmaps/tracks/frontend/state-management)
- [Client State Libraries: Zustand, Redux Toolkit and Jotai](https://www.internhack.in/roadmaps/tracks/frontend/state-libraries)
- [Server State with TanStack Query](https://www.internhack.in/roadmaps/tracks/frontend/server-state)
- [Working with REST APIs in Production](https://www.internhack.in/roadmaps/tracks/frontend/api-integration)
- [GraphQL on the Frontend](https://www.internhack.in/roadmaps/tracks/frontend/graphql-clients)
- [Forms in React with React Hook Form](https://www.internhack.in/roadmaps/tracks/frontend/react-forms)
- [Schema Validation with Zod](https://www.internhack.in/roadmaps/tracks/frontend/schema-validation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
