FSD Frontend System Design

Part III — The Speed · Lesson 6.10

State Management

In one lineSort state by who owns it — server, URL, or client — and most of the hard problem disappears.

Where you've seen itCopying a filtered search URL into Slack and having a colleague open the identical view.

  • Time17 min
  • DiagramState ownership map + the scope ladder
  • Chapter6 · Database & Caching

Diagram

diagram

Lessons in this diagram6.9 API Caching

diagram
diagram

How it works

  1. Classify first. Ask "who is the source of truth?" Server state gets a caching library, not a global store.
  2. Push filters and pagination into the URL — you get shareability, deep links, and back-button behaviour for free.
  3. Keep client state as local as possible, lifting only when a second consumer genuinely appears.
  4. Use Context for low-frequency, wide-reach values (theme, auth, locale); use a store with selectors for anything that changes often.
  5. Derive, don't duplicate. Totals, filtered lists, and counts should be computed from state, never stored alongside it.

Trade-offs

ToolFitsCost
useStateLocal UIProp drilling if over-lifted
ContextTheme, auth, localeRe-renders all consumers
ZustandGlobal client state, small APIAnother concept in the codebase
Redux ToolkitLarge apps, devtools, middlewareBoilerplate, learning curve
React QueryAll server stateNot for client-only state

Interview angle

"Which state management library would you choose?"

  • Reframe first: most of the state is server state, so the real answer is a caching library plus the URL.
  • What's left is genuinely small — theme, modals, cart — and useState plus one lightweight store usually covers it.
  • Choose Redux when you need time-travel debugging, middleware, or a large team needing strict conventions — not by default.

Recap

  • Server, URL, client, form — classify before choosing a tool.
  • Filters and pagination belong in the URL, not in a store.
  • Context broadcasts; stores let components subscribe selectively.