React State Management: useState, Context, Zustand or Redux Toolkit?

A
Author
16 May, 2026 1 min read 658 views

"Which state library should I use?" depends on what kind of state you have. Most apps need less global state than they think.

1. Server state is not app state

Data from your API (users, products, orders) belongs in a server-state tool: Server Components, TanStack Query or SWR. Moving it there often removes most of your "global state".

2. Local state first

const [isOpen, setIsOpen] = useState(false); // used by one component? keep it here

Lift state to the nearest common parent when two siblings need it. Put filters and tabs in the URL (search params) so they survive reloads and can be shared.

3. Context for rarely-changing values

Context is great for theme, locale and the signed-in user. Every consumer re-renders when the value changes, so avoid it for fast-changing data.

4. Zustand for simple global state

import { create } from 'zustand';

export const useCart = create((set) => ({
  items: [],
  add: (item) => set((s) => ({ items: [...s.items, item] })),
  clear: () => set({ items: [] }),
}));

// Components subscribe to just the slice they use
const count = useCart((s) => s.items.length);

No provider, very little boilerplate, and components only re-render when their selected slice changes.

5. Redux Toolkit for large, complex apps

const cartSlice = createSlice({
  name: 'cart',
  initialState: { items: [] },
  reducers: {
    added: (state, action) => { state.items.push(action.payload); }, // Immer makes this safe
  },
});

Choose it when you want strict patterns across a big team, powerful devtools with time-travel, or RTK Query for data fetching in the same store.

Quick decision guide

  • API data -> server-state library.
  • UI state for one area -> useState / useReducer.
  • Shareable view state -> URL.
  • Theme, user, locale -> Context.
  • Cross-cutting client state -> Zustand (small/medium) or Redux Toolkit (large).
Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.