State Managers
Redux
Redux integrates through createReduxStoreAdapter or a custom adapter object — bridging dispatchToStore's setState fallback to Redux's action dispatch model.
Prerequisites
- A Redux store from configureStore() and action creators from createSlice() — see Redux Toolkit's docs if you're new to it
- Familiarity with register() — see api/register
1
A plain Redux slice and store
Define a slice with reducers for full array replacements (
setItems), optimistic placeholder additions (addOptimisticItem), single confirmed item upserts (upsertItem), and removals (removeItem):typescript
2
Registering with createReduxStoreAdapter
For simple stores that process whole array payloads, wrap the store and action creator with
createReduxStoreAdapter:typescript
3
Why Redux needs an adapter
A Redux store only ever changes through
dispatch() — there's no native setState method. The adapter exists to give dispatchToStore's fallback path a concrete function to invoke.typescript
4
Handling sparse updates & single delta events
When streaming live updates over WebSocket, SSE, or Socket.IO, your backend streams single delta frames (
CREATE, sparse UPDATE, and DELETE) alongside initial array hydrations. Use a hand-written adapter object to route incoming data to the correct Redux action:typescript
5
Reaching for hydrateState
If you use
createReduxStoreAdapter but need to dispatch multiple actions or perform side effects upon payload arrival, pass a custom hydrateState callback during registration:typescript
typescript
Need multiple actions from one channel?
createReduxStoreAdapter is deliberately single-action. If a channel needs to fan out to more than one reducer, use hydrateState or a custom adapter object as shown above.
6
Combining with scope
Redux registrations take
scope exactly like any other state manager — the adapter layer has no awareness of multi-tenant scoping at all.typescript
7
Redux vs. other state managers
Redux is one of two state managers that benefit from an explicit adapter factory — the other being Jotai.
typescript
For Zustand, Flux's native option, see state-managers/zustand. For Jotai, see state-managers/jotai. For Stunk, see state-managers/stunk. For every other registration field alongside store, see api/register.