February 14, 2024

State Management in React: Keep It Simple

The React ecosystem has too many state management solutions. We tried several. Here's what stuck.

What We Use

Local State: For component-specific data. useState is enough 80% of the time.

Context API: For app-wide state like user auth and theme. Simple and built-in.

Server State: For data from APIs. We use SWR for caching and revalidation.

What We Don't Use

Redux: Too much boilerplate for our needs. Great for large teams. Overkill for us.

MobX: Clever, but adds magic. We prefer explicit over implicit.

Zustand/Jotai: Nice libraries. But Context API does what we need.

The Principle

Use the simplest tool that solves the problem. Don't add complexity for hypothetical future needs.

When to Upgrade

If Context API causes performance issues (it hasn't), we'll revisit. Until then, YAGNI.