Zustand vs Jotai is a comparison between two client-state libraries from the same team (pmndrs) that solve the same broad problem, keeping UI state in sync across components, with genuinely different models, one store-based and the other atom-based, and this guide has them compared side by side against TanStack Query, the third tool most 2026 production apps end up reaching for as well. You're not choosing between good and bad, they're different models that suit different problems. TanStack Query enters the picture as a third tool that solves something neither of them was designed for: caching and synchronizing server data. Pick the wrong combination and you end up either reinventing a query cache in Zustand or handling auth state in TanStack Query, both of which create friction as apps grow.
A disclosure before the comparison: I haven't needed either library in my own work. In the React projects I actually maintain, shared state lives in Context plus useState. The monorepo of eight Astro blogs I work in has 11 React islands (calculators, a gallery, a map, a comparison tool), and every one of them keeps its state in local useState, with no Context and no store. So what follows compares the two models on their documented behavior and published numbers, not on a migration I ran.
The core difference: one store or many atoms
Start with the mental model.
Zustand is a store. You describe a domain as a single object with state and actions, then subscribe to slices of it in components. It's like a Redux slice with none of the ceremony.
Jotai is atomic. There's no store. You create standalone atom() units, essentially module-level useState, and compose derived atoms from them. Each component subscribes to exactly the atoms it needs, nothing more. Jotai 3.0.1 weighs about 3.3 kB minified and gzipped on Bundlephobia, against roughly 0.5 kB for Zustand 5.1.0's main entry. On npm's download counter for the week of October 30 to November 5, 2026, Zustand logged about 91 million downloads and Jotai about 9.5 million, close to a tenfold gap. Is that a verdict on quality? I don't read it that way. Both libraries are actively maintained by the same pmndrs group, and my guess is the gap mostly reflects how many teams default to a single global store because that's the model they already know from Redux. Download counts also include CI installs and transitive dependencies, so they measure reach, not how many apps chose a library on technical merit.
| Zustand | Jotai | TanStack Query | |
|---|---|---|---|
| Solves | Client state | Client state (atomic) | Server state |
| Model | Store (one object per domain) | Atoms (one per value) | Query cache (per queryKey) |
| Bundle size (min+gzip, Bundlephobia) | ~0.5 kB (5.1.0) | ~3.3 kB (3.0.1) | ~13.3 kB (5.107.0) |
| npm downloads, week to Nov 5, 2026 | ~91M | ~9.5M | ~82M |
| Provider required | No | No | Yes (QueryClientProvider) |
| Re-render control | Selectors | Atomic subscriptions | Automatic (per query) |
| Async state | Middleware / manual | Built-in async atoms | Built-in (first class) |
| Caching | No | No | Yes, core feature |
| Background refetch | No | No | Yes (on window focus + interval) |
| DevTools | Redux DevTools | Jotai DevTools (separate pkg) | TanStack Query DevTools |
The state-library debate is really a scope question: global store, atom-level renders, or server cache. Pick by the shape of your state, not the hype.
Re-renders in each library
Re-render behaviour drives most of the Zustand vs Jotai debates online. Both give you minimal re-renders when used correctly, and only the mechanism differs. Zustand relies on you writing a selector that picks the exact slice a component needs; skip the selector and you'll re-render on every store change. In the render counts on the Zustand catalog page linked at the end of this article (Zustand 5.0.15, React 19.3.1), a component reading the whole store went from 1 render to 11 after ten unrelated changes, while one selecting a single field stayed at 1. Jotai builds the granularity into the atom model itself, so there's no selector to forget in the first place. Per the Jotai documentation, each useAtomValue call subscribes only to that specific atom's updates, not to a shared store object, so adding more independent atoms doesn't widen what any one component re-renders on.
Zustand needs a selector to get fine-grained re-renders; Jotai gets that granularity for free because each atom is its own subscription, with nothing shared to over-subscribe to by accident.
With Zustand, you use a selector:
// Only re-renders when items.length changes, not on any other mutation
const count = useCartStore((s) => s.items.length);
Writing that selector is the one rule with Zustand.
Jotai handles this automatically at the atom level:
const countAtom = atom(0);
const doubledAtom = atom((get) => get(countAtom) * 2);
// This component only re-renders when countAtom changes
const count = useAtomValue(countAtom);
No selector needed. That pays off when you have many small independent pieces of state, because there's no selector to forget.
When to choose Zustand
Zustand is the better default for most projects, and it's the one I'd reach for first on any new codebase unless I already know the app needs dozens of independent per-item toggles. Use it when:
- You're managing domain-level state: authentication, cart, user preferences, notification queues
- Your team finds store-based thinking intuitive (very similar to Redux, minus the reducers)
- You need
persistmiddleware for localStorage sync out of the box - You want Redux DevTools to inspect state history without extra setup
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
interface AuthStore {
user: User | null;
login: (user: User) => void;
logout: () => void;
}
const useAuthStore = create<AuthStore>()(
persist(
(set) => ({
user: null,
login: (user) => set({ user }),
logout: () => set({ user: null }),
}),
{ name: 'auth' }
)
);
Zustand holds up in production better than its tiny size suggests. The API is small enough to learn in an hour, and the TypeScript integration with create<StoreType>() is excellent. Bundlephobia puts Zustand 5.1.0 at about 0.5 kB minified and gzipped, while Redux Toolkit 2.14.0 (about 14.6 kB) plus react-redux 9.3.1 (about 3.9 kB) comes to roughly 18.5 kB, so the gap is closer to 35x than the 10x you'll often see quoted, and it works outside React components too, so a useAuthStore.getState() call in an Axios interceptor or a route guard reads the same state without any provider in scope. That last detail is easy to overlook and it removes a surprising amount of plumbing from a typical auth flow.
Zustand compared to Redux
Zustand replaces most of what Redux does with a fraction of the boilerplate: no action types, no dispatch, no reducer switch statements, and no separate react-redux package to wire up. The auth store above, persistence included, is ten lines of create() plus a five-line interface. Redux still wins on one thing Zustand doesn't try to solve: enforced, predictable state transitions in a large team where you want every mutation funneled through named actions for auditability. If your team already has Redux middleware, sagas, or a compliance requirement around action logging, migrating off it is rarely worth the churn. For a new codebase in 2026, Zustand is the better starting point for almost everyone else. The migration path is gentler than people assume, too, since a Redux slice and a Zustand store hold the same shape of data and you can run both side by side while you move features across one at a time.
Where Jotai is the better fit
Jotai wins in specific situations where Zustand's store model creates awkward workarounds:
- Per-item state (a
completedflag per todo, anexpandedflag per accordion item) - Complex derived values that pull from multiple orthogonal atoms
- Async atoms with React Suspense integration
- Fine-grained subscriptions where you want automatic atom-level isolation
The atomFamily pattern is cleaner than anything you'd build on top of Zustand:
import { atom, useAtom } from 'jotai';
import { atomFamily } from 'jotai-family'; // Jotai 3; on Jotai 2 it's exported from 'jotai/utils'
// One separate atom per accordion item
const expandedAtomFamily = atomFamily((_id: string) => atom(false));
function AccordionItem({ id }: { id: string }) {
const [expanded, setExpanded] = useAtom(expandedAtomFamily(id));
return (
<div onClick={() => setExpanded((e) => !e)}>
{expanded ? 'Collapse' : 'Expand'}
</div>
);
}
Each component only re-renders when its specific atom changes, with no selector and no shallow to remember. The difference shows up at scale rather than in a toy example. Render a table of 500 rows where each row has its own expanded flag, and the Zustand version either keeps 500 booleans in one store object (every toggle notifies every subscriber unless each row writes a precise selector) or splits into 500 stores, which nobody wants to maintain. Jotai's atomFamily gives you the same 500 independent subscriptions with one line of setup. Per the Jotai documentation, atoms created this way are cached by their parameter, so calling the family with the same id twice returns the identical atom rather than a new one, which is what keeps the subscription stable across renders. The same per-entity idea is what stops a live dashboard on a WebSocket stream from re-rendering every card whenever a single sensor reports.
What TanStack Query is for
TanStack Query (v5) manages server state: data fetched from an API, its loading and error states, background re-fetching, and cache invalidation. That's a different problem from what Zustand and Jotai solve, neither of them cache API responses or know when to refetch.
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
function UserProfile({ userId }: { userId: string }) {
const queryClient = useQueryClient();
const { data: user, isLoading } = useQuery({
queryKey: ['user', userId],
queryFn: () => fetchUser(userId),
staleTime: 5 * 60 * 1000, // treat data as fresh for 5 minutes
});
const mutation = useMutation({
mutationFn: (updates: Partial<User>) => updateUser(userId, updates),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['user', userId] });
},
});
if (isLoading) return <Spinner />;
return <div onClick={() => mutation.mutate({ name: 'New Name' })}>{user.name}</div>;
}
You get caching, deduplication (two components using the same queryKey share one fetch), background refetching on window focus, automatic retries, and cache invalidation on mutation. There's no equivalent in Zustand or Jotai. You'd have to build all of that by hand, and it wouldn't be as reliable.
TanStack Query doesn't replace client-state libraries. You still need Zustand or Jotai for UI flags, modal state, auth tokens, and cart contents. What it does replace is the useEffect + useState data-fetching pattern most teams were using before.
Which library your app needs
Most production React apps need 2 libraries, not 3, and the split falls along a clean line: anything that came from a server belongs to TanStack Query, anything the user did in the browser belongs to Zustand. The breakdown below covers the usual cases:
| State type | Best tool |
|---|---|
| API data, caching, background sync | TanStack Query |
| Auth, user session, cart | Zustand |
| UI flags, modal state, preferences | Zustand |
| Per-item state (per-row, per-accordion) | Jotai |
| Complex derived values from many atoms | Jotai |
| Async data with Suspense integration | Jotai (atomWithQuery) or TanStack Query |
The combination that handles most apps: Zustand + TanStack Query. TanStack Query takes over everything that touches an API. Zustand handles the rest of client state. Add Jotai only when you genuinely hit the limits of Zustand's selector model, typically when you need per-item granularity at scale.
Don't reach for all three at once. Start with Zustand and TanStack Query. If you find yourself writing Zustand selectors that feel overly complex for per-item UI state, that's the signal Jotai would help.
Choosing a state tool: three questions in order
If you'd rather decide with a procedure than a table, ask three questions in this order. The first one settles most apps before the other two come up.
1. Where did the data come from? If a server owns it (a product list, a user profile, a feed), it isn't client state, and TanStack Query should hold it. The tell is simple: if you'd refetch it after a reload and get the same answer, don't copy it into a store. Duplicating API data into Zustand or Jotai is the most common state bug in review, because the copy goes stale the moment another tab or user changes the record.
2. How far does the state reach? What's left is client state, and its scope decides the tool. State that several distant parts of the app read (session, cart, theme, a sidebar's open flag) fits one Zustand store, because a store is a single named place to look. State that belongs to one subtree, or to each item in a list, fits plain useState or useReducer first. Reach for Jotai only when you'd otherwise be creating many small, similar pieces of state, such as one flag per row. If you build with Astro islands, this question often ends here: each island hydrates on its own, so state that never leaves the island has nowhere to be shared, and plain useState is the whole answer. That's exactly why none of my own islands has a store.
3. What does a change cost in re-renders? Measure before you decide. With a Zustand selector, a component re-renders only when the slice it selected changes, so most apps never need anything finer. If the React Profiler shows a long list re-rendering because one row changed, per-item atoms are the fix, and that's the signal to bring in Jotai. If it doesn't show that, you don't have the problem.
| Question | Answer | Tool |
|---|---|---|
| Does a server own the data? | Yes | TanStack Query |
| Is it shared across distant components? | Yes | Zustand store |
| Is it local to one subtree? | Yes | useState or useReducer |
| Does per-item state re-render too much? | Yes, in the Profiler | Jotai atoms |
Two of these answers can be true at once. A shopping page usually has all four: the catalog from the server, a cart in a store, a filter panel's open state in a component, and maybe per-row quantity inputs as atoms. That isn't a reason to install everything on day one; add each tool when its question comes up.
Recent releases
None of these three libraries stood still this year, and the changes matter if you're picking today. Zustand's v5 line spent most of its cycle dropping deprecated v4 patterns instead of adding features. React 18 is now the minimum version, and use-sync-external-store became a peer dependency that only the zustand/traditional equality helpers (createWithEqualityFn, useStoreWithEqualityFn) need. The first minor in a while, v5.1.0, landed on November 6, 2026 and touches only middleware: persist now accepts PromiseLike results from storage reads and migrations, persist.rehydrate() returns a Promise<void> you can await, and devtools gained an actionCreators option for dispatching store actions from Redux DevTools.
Jotai shipped something bigger. Version 2.20 (May 2026) improved performance in high-throughput scenarios and refactored some internals. Three follow-up patches, 2.20.1 through 2.20.3, fixed smaller bugs. The bigger news is Jotai v3, released on September 8, 2026 as "a mostly backward-compatible update" that drops some legacy support and deprecated APIs. The raised minimums are React 18, TypeScript 5.5 and Node.js 22.12.0, and the CJS, UMD and SystemJS builds are gone. One change touches the accordion pattern shown above: per the v3 migration guide, atomFamily moved from jotai/utils to the separate jotai-family package, and the jotai/utils entry of 3.0.2 no longer ships it. The accordion example imports it from jotai-family for that reason; the API is the same.
TanStack Query has been quieter on the React side. Most @tanstack/react-query releases, up to 5.107.0 on November 6, 2026, are dependency bumps that pull in query-core fixes; that one keeps the timestamp stable for a repeated selector error so it can't trigger an infinite render loop. The Solid 2.0 work lives in a separate major, @tanstack/solid-query 6, which is still a release candidate (6.0.0-rc.6 on npm in late November) while the 5.x line keeps the latest tag, at 5.108.4 by then. If you're not on Solid, there's nothing here that changes how you'd use useQuery or useMutation day to day.
Net effect for anyone starting a project today: the Zustand + TanStack Query combination still holds up as the default. Import from jotai-family if you reach for Jotai's atomFamily pattern on v3, since that's the one change that touches the pattern in this post.
Can You Use All Three Together?
Yes. Zustand, Jotai, and TanStack Query don't conflict. In fact, the jotai-tanstack-query package provides atomWithQuery and atomWithMutation adapters that let you use TanStack Query's cache through Jotai's atom interface, useful in codebases already committed to the atomic model.
Don't mix all three prematurely. For most apps, even fairly complex ones, Zustand plus TanStack Query covers everything. That's the default I'd pick for any new React project. Add Jotai when you genuinely hit Zustand's granularity limits, not as a default third tool. The cost of having three state libraries in your bundle and your team's mental model is real. Bundle size is the smaller half of it, all 3 together come to about 17 kB gzipped on Bundlephobia's numbers. The bigger cost is the review question that shows up on every pull request: which of these does this piece of state belong in? Two libraries with a clear server-versus-client split answer that automatically. Three don't.
Related Guides
- Zustand, full API reference with Immer, persist, and TypeScript examples
- Jotai, atom API, atomFamily, async atoms, and Suspense integration
- TanStack Query, handles server state so neither library has to
- React Server Actions guide, React 19 Actions change how you think about client-side mutation state
- TypeScript Generics Guide, type your Zustand stores and Jotai atoms with generic patterns