Zustand or Redux Toolkit? Choosing State Management for a React App
By Muhammad Osama Khan, Software Engineer. React, Aug 25, 2026, 3 min read.
The same cart written with Zustand and with Redux Toolkit, a plain comparison, and a simple way to decide which one your app needs.
React's own useState and context cover a lot, but once many distant components share state (a cart, the signed-in user, filters) you reach for a store. Two popular choices are Zustand, a very small library, and Redux Toolkit, the recommended way to write Redux. Here is the same cart in both.
The cart in Zustand
src/store/cartStore.js
import { create } from 'zustand';
import { persist } from 'zustand/middleware';
export const useCartStore = create(
persist(
(set) => ({
items: [],
add: (product) =>
set((state) => {
const found = state.items.find((i) => i.id === product.id);
return found
? { items: state.items.map((i) => (i.id === product.id ? { ...i, qty: i.qty + 1 } : i)) }
: { items: [...state.items, { ...product, qty: 1 }] };
}),
remove: (id) => set((state) => ({ items: state.items.filter((i) => i.id !== id) }))
}),
{ name: 'cart' } // saved to localStorage
)
);src/components/CartBadge.jsx
import { useCartStore } from '../store/cartStore';
export default function CartBadge() {
// select only what you need: the component re-renders when this value changes
const count = useCartStore((state) => state.items.reduce((n, i) => n + i.qty, 0));
return <span>Cart ({count})</span>;
}There is no provider to wrap around the app and no action types. A component calls the hook and picks a slice of the state with a selector.
The cart in Redux Toolkit
src/store/cartSlice.js
import { createSlice, configureStore } from '@reduxjs/toolkit';
const cartSlice = createSlice({
name: 'cart',
initialState: { items: [] },
reducers: {
// Immer lets you write "mutating" code that is turned into an immutable update
added(state, action) {
const found = state.items.find((i) => i.id === action.payload.id);
if (found) found.qty += 1;
else state.items.push({ ...action.payload, qty: 1 });
},
removed(state, action) {
state.items = state.items.filter((i) => i.id !== action.payload);
}
}
});
export const { added, removed } = cartSlice.actions;
export const store = configureStore({ reducer: { cart: cartSlice.reducer } });src/components/CartBadge.jsx
import { useSelector } from 'react-redux';
export default function CartBadge() {
const count = useSelector((state) => state.cart.items.reduce((n, i) => n + i.qty, 0));
return <span>Cart ({count})</span>;
}
// once, at the top of the app:
// <Provider store={store}><App /></Provider>How they compare
- Size and ceremony: Zustand is a few kilobytes with almost no setup. Redux Toolkit is bigger and asks for slices, a store and a provider, but gives a consistent structure.
- Structure at scale: Redux Toolkit's named actions, reducers and conventions help a larger team keep one shape across many features. Zustand leaves the structure up to you.
- Tooling: Redux DevTools make every action and state change easy to inspect. Zustand can connect to the same DevTools through its devtools middleware.
- Server data: RTK Query ships inside Redux Toolkit and handles fetching, caching and invalidation (see the RTK Query article on this blog). With Zustand you pair it with a data library of your choice.
A simple way to decide
- Do you only need a little shared client state (a cart, a theme, a modal, filters)? Zustand is usually enough and quicker to write.
- Is the app large, with many people on it, lots of cross-feature state and a need for strict conventions? Redux Toolkit earns its extra structure.
- Are you already using RTK Query, or planning to? Then Redux Toolkit is the natural home for the rest of your state too.
Frequently asked questions
Is Zustand better than Redux Toolkit?
Neither is better in general. Zustand is smaller and quicker to set up, which suits modest amounts of shared client state. Redux Toolkit adds structure, conventions and strong tooling, which helps larger apps and teams.
Does Zustand need a provider?
No. A Zustand store is a hook you import and call. Components pick the part of the state they need with a selector, and re-render only when that part changes.
Can I use Zustand and Redux Toolkit in the same app?
Technically yes, but it is rarely worth it. Pick one for client state, and use a data-fetching library (such as RTK Query) for server data.
Where should data from an API live?
In a server-state library such as RTK Query, not in a Zustand store or a Redux slice. API data goes stale and needs caching, refetching and invalidation, which those libraries handle for you.