No. 23React8 min read2,017 words
React state management in 2026: what to use and when
React state management in 2026, for teams picking tools: server vs client state, TanStack Query, Server Components, URL state, Context, Zustand and Redux.
- Written by
- Lazy Devs
- Published
- Updated
- Sources
- Cited inline

Key takeaways ยท 05
The short version
- 01Split state into server state (data from your backend that can go stale) and client state (UI the browser owns) before choosing any library. They need different tools.
- 02Do not cache API data in a global client store. Load it in Server Components, or use a query library such as TanStack Query that handles caching, refetching and invalidation.
- 03Put filters, tabs, pagination and search terms in the URL. It makes views shareable, survives refresh, and lets Server Components read the same state.
- 04Most apps need very little global client state: useState and useReducer locally, Context for a few stable values, and a small store such as Zustand only when shared state changes often.
- 05Redux Toolkit is still a sound choice for large teams that want one strict pattern, but use RTK Query for server data and do not start new projects with hand-written Redux boilerplate.
On this page ยท 11
React state management in 2026 is calmer than the discourse suggests. Sort your state into two kinds first: server state, which is data from your backend that can go stale, and client state, which is UI the browser owns. Hand server state to Server Components or a query library like TanStack Query, put shareable view state in the URL, keep the rest local with useState, and add a small store such as Zustand only when shared client state genuinely changes often. Most apps need far less global state than they think.
Every few months someone declares a winner, and every few months a project ships with several state libraries fighting over the same data. This is the map we use on React projects to decide what goes where.
The split that matters: server state vs client state
The most useful mental model is also the one people still skip. Your app has kinds of state that have almost nothing in common.
| Kind of state | Examples | Owned by | Best home |
|---|---|---|---|
| Server state | Orders, user profile, search results | Your backend | Server Components, TanStack Query, RTK Query |
| URL state | Filters, sort order, current tab, page number | The address bar | Search params and route segments |
| Form state | Field values, validation errors, submission status | The form | Form actions, useActionState, a form library for complex forms |
| Local UI state | Open menus, hover, input focus | One component | useState, useReducer |
| Shared client state | Theme, cart, editor selection | The browser session | Context or a small store |
The classic mistake is dumping server data into a global client store and then hand-writing a caching layer: loading flags, race-condition handling, stale data, invalidation. That is the part you should never write yourself. React's own guide to managing state is worth a reread here, especially the advice to avoid duplicated and derivable state.
Do not store what you can derive
A surprising amount of "state" is just a computation. A filtered list, a total, a "has unsaved changes" flag: compute them during render from the state you already have. Copying derived values into state, then syncing them with effects, is a common source of bugs. The React team's You Might Not Need an Effect covers the patterns. With the React Compiler stable and available as a Next.js option, manual memoization of these computations matters less than it used to.
Server state: use a query library or the server
On the client: TanStack Query
For client-rendered data, TanStack Query is the default we reach for. It handles caching, deduplication, background refetching, retries and mutation invalidation.
// hooks/useOrders.ts
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
type Order = { id: string; total: number; status: "open" | "shipped" };
export function useOrders() {
return useQuery({
queryKey: ["orders"],
queryFn: async (): Promise<Order[]> => {
const res = await fetch("/api/orders");
if (!res.ok) throw new Error("Failed to load orders");
return res.json();
},
staleTime: 30_000, // fresh for 30s, so remounts do not refetch
});
}
export function useShipOrder() {
const qc = useQueryClient();
return useMutation({
mutationFn: async (id: string) => {
const res = await fetch(`/api/orders/${id}/ship`, { method: "POST" });
if (!res.ok) throw new Error("Failed to ship order");
},
onSuccess: () => qc.invalidateQueries({ queryKey: ["orders"] }),
});
}That invalidateQueries call is the point. You changed something on the server, so you tell the cache it is stale and let the library refetch. No manual store updates and no drift between the UI and the database.
On the server: Server Components
On the Next.js App Router, much of your server state never reaches the client as state at all. You fetch in a Server Component, render the result and send HTML. There is no spinner and no client cache, because the data was resolved before the page was sent.
// app/orders/page.tsx (Server Component)
import { listOrders } from "@/lib/dal/orders";
export default async function OrdersPage() {
const orders = await listOrders();
return (
<ul>
{orders.map((o) => (
<li key={o.id}>
{o.id} ({o.status})
</li>
))}
</ul>
);
}Server Actions cover writes. A form posts to an action, the action writes to the database and invalidates the affected data with updateTag, revalidateTag or revalidatePath (the machinery in our guide to Next.js caching), and the relevant Server Components re-render with fresh data.
The rule of thumb: fetch on the server when the data is needed for the first render and does not change while the user looks at it. Use TanStack Query when the data is lively: polling, infinite scroll, optimistic updates across many components. Plenty of real apps use both, and that is correct, not a smell.
If the data changes on the server while the user watches, how to build a real-time app covers pushing updates into that cache instead of polling.
URL state: the most underused store
Filters, sort order, the selected tab, the page number and the search term belong in the URL. Putting them there means:
- The view survives a refresh and the back button works.
- Users can share or bookmark exactly what they are looking at.
- Server Components can read the same state from
searchParamsand render the right data on the server.
"use client";
import { useRouter, usePathname, useSearchParams } from "next/navigation";
export function StatusFilter() {
const router = useRouter();
const pathname = usePathname();
const params = useSearchParams();
function setStatus(status: string) {
const next = new URLSearchParams(params);
if (status) next.set("status", status);
else next.delete("status");
router.replace(`${pathname}?${next.toString()}`);
}
return (
<select value={params.get("status") ?? ""} onChange={(e) => setStatus(e.target.value)}>
<option value="">All</option>
<option value="open">Open</option>
<option value="shipped">Shipped</option>
</select>
);
}Next.js's useSearchParams docs cover the details, including the need for a Suspense boundary around components that read search params in prerendered routes. Libraries like nuqs add type-safe parsing if you have many parameters.
Form state: let the form own it
Most forms do not need a store. Uncontrolled inputs with a form action, plus React 19's useActionState for the result and errors, cover the majority of forms with very little code. useOptimistic shows the expected result immediately while the action runs. Reach for a form library when you have complex validation, dynamic field arrays or multi-step wizards. Keep drafts out of global stores unless they must survive navigation.
Client state: smaller than the internet thinks
Once server data, URL state and forms are handled properly, the global client state left in most apps is tiny: a theme, a cart, maybe some editor UI. That is often the whole list.
Start with React's primitives:
useStatefor state one component owns.useReducerwhen updates have several steps or rules, so the transitions live in one testable function.- Context for a handful of values read in many places, such as theme, locale or the signed-in user.
Context is unfairly blamed for performance problems. Every consumer re-renders when the context value changes, so the problem is almost always one giant context holding values that change at different speeds. Split contexts by update frequency, keep the value stable, and the issue mostly disappears.
When you do reach for a store
If client state is shared, updated often and read in many unrelated places, a small store beats both prop drilling and a sprawling context. Zustand is the comfortable default: small, no provider required for client-only use, and little ceremony.
// stores/cart.ts
import { create } from "zustand";
type CartState = {
items: Record<string, number>;
add: (id: string) => void;
clear: () => void;
};
export const useCart = create<CartState>((set) => ({
items: {},
add: (id) =>
set((s) => ({ items: { ...s.items, [id]: (s.items[id] ?? 0) + 1 } })),
clear: () => set({ items: {} }),
}));Components subscribe to the slice they care about, for example useCart((s) => s.items[id]), so a quantity change does not re-render the whole tree. That selector-based subscription is what makes it feel light. Atom-based libraries like Jotai are a reasonable alternative when state is naturally many small independent pieces.
One App Router caveat: a store created at module level is shared by every request on the server. If server-rendered output reads from it, create the store per request and provide it through Context, so one user's state can never leak into another user's HTML.
So where does Redux fit now?
Redux Toolkit is not dead. It is no longer the default for a new app, but it remains a sound choice for large teams that want one strict, predictable pattern across a big codebase, especially where Redux DevTools and middleware pull real weight. If you already run Redux Toolkit and it works, migrating for fashion wastes a sprint. Make sure server data goes through RTK Query rather than thunks plus hand-rolled caching, because that is the part that ages badly.
What we would not do in 2026 is start a greenfield project with hand-written Redux: action-type constants, switch statements and manual immutable updates. Redux Toolkit replaced all of that years ago.
A decision guide you can use
| If the state is... | Use |
|---|---|
| API data needed on first render | A Server Component |
| API data that is interactive (polling, infinite scroll, optimistic updates) | TanStack Query, or RTK Query if you already use Redux |
| Filters, tabs, sorting, pagination, search | The URL |
| Form inputs and submission results | The form, a form action and useActionState |
| Owned by one component | useState, or useReducer for complex transitions |
| A few stable values read widely | Context, split by update frequency |
| Shared client state that changes often | Zustand or a similar small store |
| A large team wanting one strict pattern | Redux Toolkit with RTK Query |
Signs your state layer needs attention
- A global store whose main job is caching API responses.
- Several copies of the same user or settings object in different libraries.
useEffectchains that copy one piece of state into another.- A context that re-renders half the app on every keystroke.
- Filters that reset on refresh because they live only in memory.
- Loading and error flags that can be true at the same time.
Each of these is a refactor that pays for itself in fewer bugs. When we inherit a codebase, the state layer is often where the fastest wins are. Typing state as discriminated unions helps too; our take on strict TypeScript explains why, and error handling patterns in React shows the loading and error side.
How to slim down an overgrown state layer
You do not need a rewrite to fix this. We untangle state layers incrementally, one slice at a time, with the app shipping throughout:
- Inventory the store. List every top-level key in your global store and label each one: server data, URL state, form state, local UI or genuinely shared client state. Most teams are surprised by how much of it is server data.
- Move server data first. Replace one cached API response at a time with a query hook or a Server Component, then delete the reducer, actions and loading flags that held it. This is usually where most of the code disappears.
- Move view state into the URL. Filters, tabs and pagination come next. Users notice this one, because refresh and sharing start working.
- Push local state down. Anything only one component reads goes back into that component's
useState. - Re-evaluate what is left. Often a single small store or two focused contexts remain, and the heavyweight library can go.
- Add guard rails. A lint rule or code review checklist that asks "is this server state?" before anything new enters the global store stops the problem coming back.
If you are also moving to the App Router, do steps 1 and 2 as part of that migration: much of the server data your store holds can be fetched by Server Components directly, so the slice disappears rather than moving.
The short version
Sort state into server and client before you pick a tool. Give server state to Server Components or a query library, put shareable view state in the URL, let forms own their own state, and keep the rest local until sharing genuinely demands a store. Done that way, state management goes back to being plumbing, which is where it belongs.
If your state layer has grown teeth, untangling it is everyday work for our React development team. Tell us what you are dealing with.
FAQ ยท 05 questions
Frequently asked questions
What is the best state management library for React in 2026?
There is no single best library, because state comes in different kinds. For server data, TanStack Query or Server Components in Next.js. For local UI state, React's own useState and useReducer. For shared client state that changes often, a small store such as Zustand. Redux Toolkit remains a good fit for large teams that want one consistent pattern.
Is Redux still used in 2026?
Yes. Redux Toolkit is maintained and widely used in large codebases, and its DevTools and middleware remain valuable for complex client logic. It is no longer the default for new apps, because server data is better handled by query libraries or Server Components, which removes most of what Redux used to store.
Should I use Context or Zustand?
Use Context for a few values that change rarely and are read in many places, such as theme, locale or the signed-in user. Use Zustand, or a similar store, when shared state changes often and many components need different slices of it, because components can subscribe to exactly the slice they use instead of re-rendering on every change.
Do I need a state management library with Next.js Server Components?
Often much less than before. Server Components load data on the server, Server Actions handle mutations and invalidation, and the URL can hold filters and pagination. Many App Router apps need only React's built-in hooks plus a query library for the most interactive screens.
Where should form state live in React?
Usually in the form itself. Uncontrolled inputs with a form action, or React's useActionState for submission results and errors, cover most forms. Reach for a form library when you have complex validation, dynamic fields or multi-step flows, and keep drafts out of global stores unless they must survive navigation.