State Managers
Zustand
Zustand is Flux's native state manager — no adapter, no wrapper, no glue code. Pass the store hook directly to register() and Flux calls store.setState() on it directly.
Prerequisites
- A Zustand store created with create() — see Zustand's docs if you're new to it
- Familiarity with register() — see api/register
1
A plain Zustand store with dual-payload support
Writing a store for Flux requires structuring
setState to handle both initial array payloads (from cold-boot IndexedDB hydration and bootstrap) and single live delta frames (CREATE, sparse field UPDATE, and DELETE):typescript
2
Registering it
The
store field takes the Zustand hook directly — no createXAdapter() call in between, unlike Redux, Jotai, or Stunk.typescript
3
Why Zustand needs no adapter
Every state manager ultimately has to be reachable through
hydrateState or a fallback setState call. Zustand's hook already exposes setState natively, so Flux's default fallback path works on it unmodified — there's nothing an adapter needs to translate.typescript
4
Handling sparse updates with hydrateState (alternative)
If you want to keep your Zustand store actions minimal, you can delegate sparse merging and delta frame handling to
hydrateState inside the registration instead:typescript
5
Combining with scope
Zustand registrations take
scope exactly like any other state manager — the store layer is completely independent of multi-tenant scoping.typescript
6
Zustand vs. other state managers
Zustand is the only state manager Flux treats as native. Everything else uses an explicit adapter wrapper.
typescript
For Redux, see state-managers/redux. For Jotai, see state-managers/jotai. For Stunk, see state-managers/stunk. For every other registration field alongside store, see api/register.