When to Move to External State
You'll learn: how to recognize the signals that Context performance optimizations have hit their limits and it's time to adopt a dedicated external state library.
The Turning Point
You've split contexts by concern, separated state from dispatch, memoized providers, and maybe even implemented a selector pattern with useSyncExternalStore. Yet you're still seeing:
- Too many context providers stacked in your component tree (five or more)
- Complex selector logic just to avoid re-renders
- Performance compromises where you can't share state without triggering unwanted updates
- Developer friction — every new piece of shared state requires architectural decisions
This is the moment to consider external state libraries like Zustand, Jotai, or Valtio.
Why External Libraries Solve This
Context was designed for infrequent updates (theme, auth, locale). When you're fighting Context's re-render behavior with elaborate workarounds, you're using the wrong tool.
External state libraries offer:
- Granular subscriptions — components subscribe only to the exact slice of state they need
- No provider nesting — state lives outside React's tree
- Simpler mental model — no splitting strategies, no selector gymnastics
- Better performance by default for frequently-updated shared state
Think of it like this: Context is a bulletin board where everyone watching it sees every update. External state is a library catalog where you check out only the books you need.
The Decision
If you've exhausted Context optimizations and still see performance issues or your codebase has become harder to maintain because of Context complexity, it's time to migrate. The library handles what Context fundamentally can't: fine-grained reactivity.
Key Takeaway: When Context optimization patterns create more complexity than they solve, or performance still suffers after applying all techniques, migrate frequently-updated shared state to an external library designed for granular subscriptions.