Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 41 ยท Getting Started

When to Use Redux

Decide whether Redux fits your app. Compare it with useState, Context and server-state libraries, learn the signs of too much shared state and use a simple scoring checklist.

Redux is a good tool, but it is not a default you must add to every project. It trades extra structure (actions, reducers, selectors) for predictability and shared visibility. If your app does not need those, a simpler tool wins. This lesson gives you a way to decide, based on the shape of your state and your team, instead of on fashion.

A useful first step is to split state into kinds. Much of what people once put in Redux, such as lists fetched from an API, is now better handled by a data-fetching library. What remains (the shared, client-side, "app-owned" state) is where Redux shines.

Kinds of state

Kind Example Best home
Local UI state Is this dropdown open? A text input value useState in the component
Shared UI state Current theme, sidebar open, active modal Context, or a store
Client domain state Cart contents, a draft document, filters A store such as Redux
Server state Products from /api/products, user profile A fetching/caching tool (RTK Query, TanStack Query)
URL state Current page, search query, selected tab The router
Form state Field values and errors while typing A form library or local state

Redux Toolkit includes RTK Query for server state, so choosing Redux does not mean writing fetch logic by hand. You will meet it in the Async Logic and Data Fetching chapter later in the course.

Signs Redux will help

  • Many components in different places read the same data and a change must reach all of them.
  • State changes in many ways. Ten different events can alter the cart; one reducer keeps the rules in one place.
  • You need to understand "how did we get here?" The action log and DevTools answer that.
  • The app is large and has many developers. Redux gives everyone the same structure and vocabulary.
  • You need logic around updates, such as logging, analytics, undo, saving drafts to storage or syncing over a socket. Middleware is made for this.
  • State must survive or be restored: persistence, server-side rendering hydration, or replaying a bug report.

Signs you do not need it (yet)

  • The state is local to one screen and one or two components.
  • The data mostly comes from a server and the rest is a few toggles.
  • You are building a prototype, a landing page or a small tool.
  • Updates are simple and nobody needs a history.

Start simple. Moving state from useState to a Redux slice later is a small, mechanical change, especially with Redux Toolkit. Adding Redux on day one "just in case" often costs more than it returns.

Redux versus the alternatives

useState and useReducer. Perfect for local state. useReducer uses the same (state, action) idea as Redux, so everything you learn here carries over. See the React lessons on reducers and state management libraries.

Context. Good for values that change rarely (theme, current user). Every consumer re-renders when the context value changes, which hurts when the value changes often. Redux with selectors lets each component subscribe to just the part it uses.

Zustand, Jotai and similar. Lighter stores with less ceremony. They are a fine choice for small and medium apps. Redux's strengths are its conventions, DevTools, middleware ecosystem and the fact that large teams already know it. The React course has a comparison.

TanStack Query or RTK Query. Handle caching, loading flags, refetching and invalidation of server data. They are complementary: you can use Redux for client state and one of these for server state.

A scoring checklist

Run the example below and change the answers. It is a rough aid for thinking, not a rule. Each yes adds one point; three or more suggests a store is worth it.

JS A rough Redux checklist

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Sorting your own state

Write the state of a feature down and label each piece. The labels tell you where it belongs.

JS Where should this state live?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The result is usually a small store: a handful of slices holding the truly shared client state. That is a healthy Redux app. A store holding every flag and every API response is a sign that state was moved there without thinking.

Common objections, answered

  • "Redux has too much boilerplate." That was true of hand-written Redux. Redux Toolkit removes most of it: one createSlice replaces action types, action creators and reducer.
  • "It is slow." Redux itself is fast. Slowness comes from selecting too much state or creating new objects in selectors; the course covers selectors in detail.
  • "Context does the same thing." Context transports a value; it has no update rules, no DevTools and no subscription granularity.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which kind of state is usually best handled by a server-state tool such as RTK Query?

    Data that lives on a server benefits from caching, refetching and loading flags, which RTK Query or TanStack Query provide.
  2. 2. A page has a single toggle used by two neighbouring components. What is the simplest solution?

    Two neighbouring components can share state through their common parent. A global store would be overkill.
  3. 3. Which is a genuine reason to choose Redux?

    Redux shines when shared client state has many readers and many writers, and when debugging history matters.
  4. 4. What is true about Context compared with Redux selectors?

    All consumers of a context re-render when its value changes. Selectors let components re-render only when their selected value changes.

Summary

  • Classify state first: local, shared client, server, URL, form.
  • Redux fits shared client state with many readers and writers, especially in large teams.
  • Server data belongs in RTK Query or TanStack Query, not hand-written reducers.
  • Start with useState or useReducer; moving to Redux later is easy.
  • A healthy Redux store is small and holds only genuinely shared state.

Next: Setting Up a Redux Project