Zustand

A small store library for client state. A store is a hook created from set, get and actions; components read it through selectors and re-render only when their selected slice changes, and getState() reads it outside React.

Minimal example

ts
const count = useCart(s => s.lines.length);
useCart.getState().clear();

Learn this concept

Lesson 4.12 · Persisting Zustand state

Used in exercises

Exercise 4.13 · Persisted cart store Exercise 4.15 · Item configurator screen Exercise 4.16 · Cart screen Exercise 4.21 · Cart synchronization helper Exercise 5.12 · Rider mode and customer tracking screens