Skip to content

Proposal: Deprecate Zustand in Favor of TanStack Query + Context #92

@ollioddi

Description

@ollioddi

Proposal: Deprecate Zustand in Favor of TanStack Query + Context

Summary

I propose we deprecate Zustand for new development and gradually migrate away from it. The problems it was designed to solve now have simpler solutions built into React and TanStack Query (Which mobile also uses).

Current State

Parts of our legacy codebase use Zustand for global state management. However, none of our new code uses it - we've naturally gravitated toward TanStack Query and React Context instead.

AFAIK there is currently only 1 file using this as a dependency:

Image

Why This Change Makes Sense

  1. React has evolved - The Context API + hooks now handle most state sharing needs without external dependencies

  2. TanStack Query already handles most "global state" - Data fetching, caching, mutations, and invalidation account for ~90% of what previously required global state libraries

  3. Reduced complexity - Two patterns instead of three:

    • Server state → TanStack Query
    • UI state → React Context (when needed)
    • Global state → Zustand ← Remove this layer
  4. Alignment with mobile - Our mobile app uses TanStack Query + Context successfully. Why maintain different patterns?

  5. Fewer dependencies - One less library to maintain, update, and onboard new developers on

Proposed Approach

  • New features: Use TanStack Query + Context only
  • Existing Zustand code: Leave as-is unless actively refactoring that area
  • During refactoring: Migrate server data to TanStack Query, UI state to Context

When Would Zustand Still Make Sense?

Admittedly, in scenarios with:

  • Dozens of unrelated components sharing complex client-side state
  • Proven performance bottlenecks from Context re-renders
  • Heavy derived state computations

I don't think this describes our app - but open to discussion.

Open Questions

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions