Skip to main content

Choosing the right state tool

The right state tool depends on the state category.

Do not begin architecture by choosing a library.

Begin by identifying ownership.

The decision tree​

What kind of state is this?
Local interaction / UI?useState / useReducer
Shared subtree environment or feature state?Context (+ reducer when useful)
Structured shared client state?Redux Toolkit / Zustand
Remote or server-owned data?TanStack Query / framework server cache
Complex form lifecycle?React Hook Form
Shareable navigation state?URL / router

Comparison matrix​

ToolBest fitSource of truthSubscription modelMain risk
useStatelocal UI statecomponentReact render treelifting too early
useReducerlocal/feature transition modelcomponent/providerReact render treeusing reducer for side effects
Contextsubtree-wide dependency/state accessprovider ownerContext valuegiant broad providers
Redux Toolkitstructured shared client stateRedux storeselectorsglobal dumping ground
Zustandlightweight external client stateZustand storeselectorshidden module-global coupling
TanStack Queryserver state/cache lifecycleserver + query cache snapshotquery observerstreating cache as client-owned truth
React Hook Formform values/validation metadataform controlfield/form subscriptionsduplicating values into global state
URL/routernavigable/shareable stateURLrouter/locationsyncing duplicate client state

Question 1: Who owns the authoritative value?​

Examples:

Name the source of truth first
Modal open
Component.
Cart draft
Client feature/store.
Product inventory
Server.
Search page
URL.
Checkout fields
Form draft.

If you cannot name the authoritative owner, adding a library usually makes the ambiguity worse.

Question 2: How long should it live?​

State lifetime spectrum
Component lifetime
Route lifetime
Feature lifetime
Application lifetime
Browser session
Persisted local
Server/cache lifetime

A tooltip should not accidentally live for the whole application.

A multi-route checkout draft may intentionally outlive one screen.

Question 3: Who needs it?​

Consumer scope changes the architecture
One component
Siblings
Feature subtree
Distant features
Multiple React roots
React + non-React

Scope strongly influences the architecture.

Question 4: How often does it change?​

Update frequency affects subscription needs
Theme
Rarely.
Form input
Every keystroke.
Pointer position
Many times per second.
Server inventory
Whenever backend state changes.

High-frequency shared data makes subscription granularity more important.

Question 5: Is the data remote?​

If the authoritative data lives on a server, ask whether you need:

  • caching;
  • freshness/staleness;
  • background refetch;
  • retries;
  • invalidation;
  • pagination;
  • optimistic reconciliation.

If yes, this is server-state territory.

Do not rebuild these semantics in Context, Redux, or Zustand unless you have a deliberate custom requirement.

Question 6: Does it belong in the URL?​

If users should be able to:

  • bookmark it;
  • share it;
  • refresh without losing it;
  • use back/forward navigation;

then URL state may be the correct source.

Examples:

/search?q=react&page=2
/dashboard?team=payments&range=30d

Context vs Redux Toolkit​

Choose Context when:

  • tree scope is meaningful;
  • state is coherent within one feature/environment;
  • event/middleware/devtools requirements are low;
  • subscriber granularity is acceptable.

Choose Redux Toolkit when:

  • state spans many domains/features;
  • action-driven transitions matter;
  • middleware/traceability matters;
  • normalized data or strong public selector APIs matter;
  • teams benefit from explicit store conventions.

Context vs Zustand​

Choose Context when provider placement clearly expresses ownership.

Choose Zustand when:

  • external store lifetime matters;
  • non-React access matters;
  • selector-level subscriptions are valuable;
  • a lightweight multiple-store architecture fits.

Redux Toolkit vs Zustand​

Redux Toolkit vs Zustand
Redux Toolkit

Stronger conventions · event/reducer model · middleware · DevTools · public selector APIs.

Zustand

Lighter store API · actions · selector subscriptions · lower ceremony.

A team that needs strict shared conventions may value Redux's structure.

A focused client-side feature may benefit from Zustand's smaller API surface.

Redux Toolkit vs TanStack Query​

Redux Toolkit core is for client state.

RTK Query/TanStack Query are server-state tools.

If an application already uses Redux extensively, RTK Query may integrate naturally.

If Redux is otherwise unnecessary, TanStack Query can provide server-state behavior without adding Redux architecture.

Zustand vs TanStack Query​

Do not ask "which is better?"

Ask:

Ownership decides the category
Who owns the data?
Client
Zustand may fit.
Server
TanStack Query may fit.

A UI can use both.

React Hook Form vs global store​

Form input values are usually a local workflow draft.

Form-specific ownership
React Hook Form

Values + validation + dirty/touched + dynamic fields.

Do not mirror every keystroke into Redux/Zustand unless another part of the product genuinely requires live shared ownership.

Example: SaaS dashboard​

SaaS dashboard state ownership
URL
Workspace ID · date range · filters.
TanStack Query
Workspace · analytics · users.
Context
Locale / feature environment.
Zustand
Dashboard editor layout interactions.
React Hook Form
Report configuration form.
useState
Local popover open/closed.

No single store owns everything.

Example: ecommerce​

E-commerce state ownership
TanStack Query
Catalogue · inventory · account orders.
Redux Toolkit / Zustand
Client-owned cart / checkout workflow when justified.
React Hook Form
Shipping + billing draft.
URL
Search filters · category · page.
Context
Currency / locale.

Red flags​

A state architecture needs review when:

  • one tool owns every category;
  • the same data exists in two stores;
  • API data is copied into Redux/Zustand after every query;
  • form fields are mirrored into a global store without reason;
  • URL filters are duplicated and synchronized manually;
  • authorization depends on client state;
  • state lifetime is longer than the feature that owns it.

Interview framework​

When asked "Which state library would you use?", do not answer with a brand first.

A senior answer sounds like:

Senior state-tool answer framework
1 · Classify the state
2 · Identify source of truth
3 · Define lifetime + scope
4 · Inspect update frequency + subscriptions
5 · Check persistence / URL / server requirements
6 · Choose the smallest tool that fits

Interview questions​

Mid-level: Why is URL state different from global client state?

Senior: How do you decide between Context and Zustand?

Senior: Why should server state usually not be copied into Redux/Zustand?

Staff: How would you audit a large application that uses Redux, Zustand, TanStack Query, Context, and React Hook Form simultaneously?

References​