Concepts

State Management

Patterns and libraries for managing frontend application state predictably, from local component state to shared global state.

seed#state-management#redux#zustand#react#frontend#patterns

What it is

State management is how a frontend application organizes, updates, and shares data between components. As applications grow, state becomes complex: server data, UI state, forms, cache.

State levels

LevelExampleTool
LocalMenu toggleuseState
SharedTheme, current userContext, Zustand
ServerAPI dataTanStack Query, SWR
URLFilters, paginationURL params
FormInputs, validationReact Hook Form

Evolution in React

EraSolutionModelTradeoff
2015ReduxGlobal store, actions, reducersPredictable but verbose
2018Context APINative shared stateSimple but unnecessary re-renders
2020+Zustand/JotaiAtomic stores, minimal boilerplateLightweight, less structure
2020+TanStack QuerySeparate server state from clientRequires thinking about cache invalidation

Key principle

Use the simplest tool that solves the problem. Most applications don't need a global store.

Why it matters

State management is the most complex problem in frontend development. Choosing the right strategy — local, global, server, URL — determines the application's complexity, performance, and maintainability. There is no universal solution.

References

Concepts