Skip to the page

State management and data fetching · senior

Choosing where state lives: server, client, URL and form state

Senior state-management answers start by classifying state: server data is a cache (TanStack Query, RTK Query, Server Components), shareable view state belongs in the URL, local UI state stays in components, form state goes to a form tool, and only truly shared client state needs a store.

The notes

What you must know

  • Server state: owned by the server, you hold a copy that goes stale. Needs caching, dedupe, background refresh, invalidation. Use TanStack Query, RTK Query, SWR or Server Components, not hand-written Redux slices.
  • URL state: filters, sort, page, selected tab if shareable. Survives refresh, back button and sharing.
  • Local UI state: open/closed, hover, input text: useState in the component that uses it.
  • Form state: react-hook-form or React 19 Actions.
  • Shared client state (cart before checkout, theme, wizard progress): Context for low-frequency values; Zustand or Redux Toolkit for frequent updates and many readers.
  • Pick the smallest tool per category and name migration triggers (many cross-cutting updates, need for devtools/time travel, team size, performance problems).
  • Cross-tab sync: the storage event or BroadcastChannel.
  • Team disagreement ("we want Redux"): agree on criteria, prototype both on one feature, write an ADR, revisit later.

The red pen

Common traps: mistake → fix

  • Mistake: "Put everything in one global store"

    Fix: server data becomes stale copies with no invalidation story.

  • Mistake: "Redux is dead" or "Redux always"

    Fix: both are dogma; argue from requirements.

  • Mistake: "Context is a state management library"

    Fix: it is transport; the state lives somewhere else.

Easy to hard

Questions interviewers ask, easy to hard

  1. Product list with filters, cart, signed-in user, live order status: how would you manage state?
  2. Which of these is server state, client state, URL state, form state?
  3. What would make you move from Context to Zustand or Redux?
  4. How do you keep the cart in sync across tabs?
  5. Your team wants Redux and you think it is overkill. How do you handle it?

Practise

Practise with these questions

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview