advanced 2 min answer

A front-end team wants to replace their global state library because "state management is unmanageable". How do you evaluate the request?

frontendstatearchitecturerefactoring
Show the full answer Hide the answer

Ask what is actually in the store

The complaint almost always resolves to one distinction not having been made: server state versus UI state.

Server state is data owned by the backend and held on the client as a cache. It can be stale, refetched, invalidated, shared between components, and needs loading and error representations. It is a caching problem.

UI state is local and authoritative — which tab is open, whether a modal shows, scroll position. It cannot be stale because nothing else owns it.

Putting both in one global store treats the first as though it were the second. There is no staleness model, no revalidation, and the developer manually writes into the store after every mutation — which is cache invalidation implemented by hand without being named as such.

The symptoms that confirm it

Manual cache updates after every mutation. Bugs where an item is deleted and reappears on navigation. Loading and error flags maintained by hand per resource. Components refetching the same data because sharing it was too awkward.

If those are present, the library is not the problem.

The change to propose

Move server state to a data-fetching layer with caching, deduplication, background revalidation and retry built in. Keep UI state local to the component that owns it, lifted only when genuinely shared.

The global store usually shrinks to a handful of genuinely global values — the current user, theme, feature flags — at which point the library choice stops mattering, which is the outcome that tells you the diagnosis was right.

When a replacement is justified

If the library is unmaintained, incompatible with a required framework version, or genuinely unable to express the application's needs. Those are real and they are a smaller category than the request suggests.

What to say

Agree the problem is real. Propose the separation first, as a bounded piece of work on one or two screens, and re-evaluate. If the pain persists after that, the library argument has evidence behind it.