Using Zustand?

Zustand store causing re-render storms? We unstick it.

Zustand is deliberately small, and that is why it ends up misused. A selector that returns a fresh object every render, an immer middleware wired around another middleware in the wrong order, or a persist layer that rehydrates after the first paint can all look like React bugs when the trigger is really in the store. We read the devtools, trace the subscribers, and rework the store so the tree renders when it should and holds still when it should not.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

zustand-store.log

still thrashing

What it is

Zustand at a glance

Zustand is a small state management library for React, written by the Jotai and React Three Fiber author Daishi Kato and the Poimandres collective. It gives you a store with a hook, selectors and middleware, and nothing else. No provider is required at the root, no context ceremony, and no reducer boilerplate unless you want one.

By 2026 it has quietly become the default lightweight choice for shared client state in React apps. Redux is still used, Jotai has its niche, and signals are popular in other frameworks, but for the common case of a handful of shared slices Zustand is usually what teams reach for. It composes with TanStack Query on server state and leaves the UI state to the store.

Type
State management library for React
First released
2019
License
MIT, permissive
Maintained by
Poimandres collective, led by Daishi Kato
Typically used for
Shared client state in React, replacing lightweight Redux stores, UI state across routes

The honest version

Zustand pros and cons

No technology is all upside. This is where Zustand earns its place and where it tends to cause trouble.

Where Zustand is strong

  • Almost no boilerplateA store is a function that returns state and actions. There is no reducer, no provider, no action type constant file, and the common case is fewer lines than the equivalent useReducer would be.
  • Selectors keep renders narrowComponents subscribe to the specific slice they read, so a change to one field does not force a tree-wide rerender the way raw context would.
  • Middleware stack is composablepersist, devtools, immer, subscribeWithSelector and combine wrap in a predictable order and can be mixed with custom middleware without fighting the core.
  • Works outside React tooThe store is a plain object with getState and setState, so background workers, test setups and even non-React code can read and update state without hooks.
  • Good TypeScript ergonomicsThe create helper infers the shape from the initializer, slices compose cleanly, and the StateCreator type covers the common patterns including middleware layering.
  • Small bundle footprintA few kilobytes gzipped for the core, which matters on marketing pages and embeddable widgets where every kilobyte shows up in Core Web Vitals.

Where Zustand bites

  • Selectors that return new references every callA selector that maps or filters inside the hook returns a fresh array or object every render, which defeats the equality check and causes exactly the storm you were trying to avoid.
  • Middleware order is load bearingpersist around devtools and immer around persist behave differently than the reverse. Getting the order wrong produces subtle bugs like rehydration that silently discards actions.
  • No enforced structureBecause there is almost no opinion, teams end up with one monster store, a dozen tiny stores, or a mix of both in the same codebase. Convention has to come from the team.
  • Hydration with SSR needs thoughtPersist rehydrates asynchronously and the first render on the client can see a different snapshot than the server used, which shows up as hydration warnings that take a while to diagnose.
  • Debugging without devtools is awkwardThe devtools middleware is optional and often left out in production. When a store misbehaves and the time traveling debugger is not wired up, you are reading console logs.
  • Overlap with server state causes confusionTeams that start putting API data in the store without a cache strategy reinvent half of TanStack Query by hand and end up with stale data problems.

Sound familiar?

Common Zustand problems we fix

The Zustand problems that bring people to us, and what you have once each one is fixed.

subscribeWithSelector: selector returned new reference every call

Every store update re-renders the entire app

A selector that returns a fresh object or array on each read, so the default referential equality check sees a change and schedules a render. shallow equality or a stable selector fixes it.

Renders scoped to real changes

immer: tried to modify a frozen object

Immer middleware throws on an update

An update that reached into the state after the produce block returned, or a slice that was not created inside the immer initializer. Either leaks a draft out of its lifetime.

Updates stay inside the draft

persist: hydration finished, but state was already mutated

Persisted state does not match after a reload

Actions firing before persist finished rehydrating, so the restored snapshot overwrites changes made during the first paint. onRehydrateStorage plus a hydrated flag keeps the order right.

Hydration and actions in the right order

Maximum update depth exceeded

A useEffect reads and writes the same slice

An effect subscribed to a value that it also updates, so every update triggers another run. Usually fixed by selecting only the field you need or moving the write into an action.

Effects no longer loop on themselves

TypeError: proxy revoked (immer draft used outside of produce)

A draft leaked out of its scope

A function saved a reference to a draft field and used it after the produce block ran, which immer no longer allows because the proxy has been revoked.

Draft stays inside produce

React detected a state update on an unmounted component

Store subscription warns on unmount

An async action that resolves after the component is gone and calls setState on a slice it no longer owns. The cleanup path has to cancel or bail out before the write.

Async updates respect unmount

devtools: action @@INIT

Devtools timeline is unreadable

Every anonymous set call shows up with the same name in the Redux devtools, so you cannot tell what triggered what. Named actions make the timeline useful.

Actions readable in devtools

store.subscribe fired 847 times in the last second

A subscription storm from one bad selector

A component or effect subscribed with a selector that computes a new value on every call, pulling the subscription callback onto the hot path.

Subscriptions stable under load

What we do

Zustand help, from one bad selector to a clean store layout

Call us for one looping effect, or hand us the whole store architecture.

Rescue
Re-render storms, hydration warnings, or a persist layer that will not restore. We diagnose from the devtools timeline and the subscribe counts rather than guessing.
Selector and slice design
Selectors that are stable under equality, slices that compose cleanly, and a layout that scales past the toy store without turning into a maze.
Middleware stack review
persist, devtools, immer and subscribeWithSelector ordered deliberately, with tests that prove rehydration and time travel still behave.
Migrations from Redux or Context
Moving a legacy Redux store or a context-based blob into Zustand without a big-bang rewrite, slice by slice while the app keeps shipping.
SSR and hydration
Next.js app router and Remix setups with persist and devtools wired up so the first client render agrees with the server, not fights it.
Managed Tech
A standing review of store size, action frequency, selector stability and devtools health, plus support for the one-off emergencies that always land on a Friday.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Zustand alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Zustand questions

Something else? Call+1 737 727 7327

Why is our app re-rendering so much after moving to Zustand?

Almost always a selector that returns a new reference each time. If the hook reads useStore(s => s.items.filter(...)), every call produces a fresh array and the equality check reports a change. Either move the filter outside, memoize it, or use the shallow equality helper.

Should we use one big store or many small stores?

One store with slices is easier to reason about for most apps because actions can touch multiple slices in a single update. Multiple stores make sense when the pieces truly do not interact and have very different lifetimes, like an auth store and a feature-flag store.

How do we make persist work with Next.js app router?

Guard the persist middleware so it only runs on the client, use onRehydrateStorage to flip a hydrated flag, and gate any UI that depends on persisted state on that flag. Otherwise the first client paint runs before storage is read and React complains about the hydration mismatch.

Zustand or Redux Toolkit in 2026?

For most new apps Zustand is lighter and faster to work in. Redux Toolkit still wins when you need the ecosystem around it, like RTK Query integrated with the devtools, or when the team already has deep Redux muscle memory. We have migrated both directions and will say which is a better fit for the codebase you describe.

Does Zustand replace TanStack Query?

No. Keep server data in TanStack Query where caching, deduping and background refetching already work. Keep client UI state in Zustand. Mixing them is fine; putting API responses directly in Zustand usually ends up reinventing a cache poorly.

How much does Zustand help cost?

The first look is free. Share a slice or two, point us at the renders that worry you, and we come back with a price before any work is booked.

Free estimate

Zustand giving you trouble?

Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.