Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
30

Frontend System Design · Lesson 30 of 86 · 4 min

State Patterns: Redux, Zustand and Context

This lesson is about justifying your choice of state manager in an interview, not just listing its features.

After this, you'll be able to explain the specific trade-offs between Context, Zustand, and Redux for a given system design problem. You'll know which tool to reach for and how to defend that choice.

When to use React Context (and when not to)

Use React's built-in Context for global state that changes infrequently. Think theme (light/dark mode), user authentication status, or language preference. Its purpose is to avoid "prop drilling"—passing props down through many layers of components.

It is not a general-purpose state management library.

The trap: Proposing Context for anything that updates frequently, like form state or notifications. When a context's value updates, every component that consumes it re-renders. If your context holds a large object, a change to any single property triggers a cascade of re-renders across your app, even in components that don't use that specific property. This is a common source of performance problems.

An interviewer might ask you to design a "toast" notification system. If you suggest Context, they will immediately ask about performance when multiple notifications are rapidly added and removed. A better answer involves a tool designed for frequent updates.

If you must use Context for slightly more dynamic data, split it into multiple, smaller providers. A ThemeProvider and an AuthProvider are better than a single AppProvider holding both theme and user objects. This limits the blast radius of re-renders.

Choosing a centralized store: Redux vs. Zustand

When state updates are frequent or complex, you need a centralized store. This pattern moves state logic out of your components into a single, global location. Both Redux and Zustand follow this model.

The data flow is a predictable loop: a component dispatches an action, the store runs logic to produce a new state, and then the store notifies subscribed components to re-render with the new data.

Zustand is the modern, lightweight default. It's minimal, fast, and unopinionated. Its key advantage over a naive Context implementation is selective subscription. Components can subscribe to specific slices of the store, so they only re-render when the data they actually care about changes.

This is what that looks like. Notice the selector function (state) => state.count. This component will only re-render when count changes, not when other properties in the store change.

import { create } from 'zustand';

// 1. Define the store
interface CounterState {
  count: number;
  increment: () => void;
}

export const useCounterStore = create<CounterState>((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
}));

// 2. Use it in a component with a selector
function CounterDisplay() {
  const count = useCounterStore((state) => state.count);
  return <h1>Count: {count}</h1>;
}

Redux is the heavy-duty tool for managing complexity at scale. You should reach for Redux when you have a large, complex state tree with many interdependencies, or when working on a large team that benefits from its strict, opinionated structure.

Its value comes from predictability and tooling. The unidirectional data flow, middleware for side effects (like API calls), and unparalleled Redux DevTools (which allow for time-travel debugging) are invaluable for diagnosing issues in complex applications.

The trap: Talking about "Redux" without mentioning Redux Toolkit (RTK). RTK is the modern standard. It eliminates the boilerplate (action types, creators, switch statements) that gave classic Redux its reputation for being verbose. If you're discussing Redux in an interview, you should be discussing RTK.

How to articulate the trade-offs

In a system design interview, you'll be given a problem and asked for a technical approach. Your choice of state manager reveals your understanding of complexity, performance, and team dynamics.

Frame your answer around the problem's specific constraints.

Scenario: "Design a settings panel for user preferences."

Your answer: "I'd use React Context. The data (theme, language) changes infrequently, triggered only by explicit user action. The main goal is to avoid prop drilling, and the performance cost is negligible. A full-blown state library would be over-engineering."

Scenario: "Design a shopping cart."

Your answer: "Zustand is a great fit here. The cart state (items, quantities, total) updates frequently as the user shops. We need efficient re-renders; for example, the mini-cart icon in the header should update without re-rendering the entire page. Zustand's selective subscriptions handle this perfectly with minimal boilerplate."

Scenario: "Design a collaborative document editor like Google Docs."

Your answer: "This is a case for Redux. The application state is highly complex and interconnected: document content, user cursors, comments, and real-time collaboration events. Redux's strict, predictable flow and powerful middleware are essential for managing this complexity. The time-travel debugging capabilities of Redux DevTools would be critical for tracking down bugs in such a state-intensive application."

What an interviewer is listening for is not "Redux is best," but "For this specific problem, I'd choose X because its strengths align with the core challenges A and B, while avoiding the drawbacks of Y and Z." It demonstrates mature engineering judgment.

Try it

Implement a simple "toast" notification system. Create a global store that holds an array of notification objects. One component should have a button to add a new notification to the array. A separate NotificationContainer component should render the list and automatically remove notifications after 3 seconds.

Build it with Zustand first. Then, consider how you would build it with Context. What specific performance problem would you anticipate with the Context approach as you add and remove notifications rapidly?

Next: We'll cover how to handle the data that populates these stores in Data Fetching: React Query and SWR.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Global State vs Local Component State

Next

Data Fetching: React Query and SWR