How stores actually work: subscriptions, selectors, and why re-renders explode in large apps. Build an external store, see structural sharing in action, connect it to React with useSyncExternalStore, and learn when Redux, Zustand, Jotai, or XState fits.
In a small app, useState and a bit of context are enough. At scale, the same state code starts failing in predictable ways:
user.preferences, and nobody knows which change caused a bug.isLoading: true and error: "..." at the same time, because the state is a bag of booleans.Before picking a library, separate what kind of state you have. Server data (users, products) belongs in a query cache (see the Data Fetching tutorial). URL state (filters, page) belongs in the URL. Form state belongs in the form. What's left, true client state shared across distant parts of the UI, is usually much smaller than people expect.
For that remaining state, every serious solution is built on the same three ideas, which this tutorial builds from scratch:
getState, setState, and subscribe.