Goal: state that has one source of truth and predictable updates.
Use for:
- deciding where state should live
- separating server cache from local UI state
- fixing duplicated, out-of-sync, or tangled state
Workflow:
- Classify state: server data, URL, local UI, or global app.
- Keep each piece in one place; derive the rest.
- Manage server data with a caching/query layer, not hand-rolled.
- Keep global state minimal; colocate local state.
- Make updates explicit and traceable.
- Verify consistency across components after changes.
Categories:
- server cache: fetched data with its own freshness rules
- URL state: shareable, navigable parameters
- local UI state: ephemeral, component-scoped
- global state: truly app-wide, kept small
Rules:
- one source of truth per piece of state
- derive values; do not store what you can compute
- do not put server data in global state by hand
- lift state only as far as it is actually shared