Building blocks of a client architecture · core
Server state, client state and URL state
Separate server state (cached copies of backend data, owned by a query cache), client state (UI-only, like an open panel or a draft) and URL state (filters, page, tab), and pick the right tool for each instead of one global store.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Server state is async, shared and can go stale: use TanStack Query, RTK Query, SWR, Apollo or Relay for caching by key, deduping, staleTime, background refetch, retries and invalidation.
- Client state: local UI state with useState/useReducer; app-wide but rarely changing (theme, current user) in Context; frequently changing shared state in Zustand or Redux Toolkit with selectors.
- URL state: search query, filters, sort, page, selected tab. It is shareable, survives reload and works with Back. Use replace for typing, push for real navigation.
- Form state is its own kind (React Hook Form, or React 19 Actions with useActionState).
- Derived state is computed, not stored (filtered list, counts, isValid).
- Persisted state: localStorage is small, synchronous and strings only; IndexedDB is large and async. Rehydrate carefully to avoid SSR hydration mismatches.
- React 19's useOptimistic shows an optimistic value while an Action runs; Server Components can fetch on the server so read-only pages need less client cache.
The red pen
Common traps: mistake → fix
Mistake: Big apps need Redux
Fix: a query cache removes most server-data Redux code; keep Redux for real client workflows.
Mistake: Copy fetched data into useState
Fix: two sources of truth that drift apart.
Mistake: Context is a state manager
Fix: it is dependency injection; every consumer re-renders when the value changes.
Easy to hard
Questions interviewers ask, easy to hard
- How would you manage state in this app?
- What goes into the URL and why?
- RTK Query vs TanStack Query vs fetch in useEffect?
- Two components show the same user. One edits the name. How does the other update?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.