Migration Guide
StateMesh can replace multiple libraries. This guide covers the conceptual mapping from common React state management patterns.
From Redux + RTK Query
| Redux | StateMesh |
|---|---|
createStore | createMesh |
useSelector | useMeshSelector / useMeshState |
useDispatch | useMeshAction / actions |
createSlice | mesh.action() |
createAsyncThunk | mesh.transaction() |
RTK Query useQuery | useMeshResource |
RTK Query useMutation | useMeshMutation |
redux-persist | mesh.persist() |
redux-undo | mesh.undo() / mesh.redo() |
Key differences:
- No reducers, no action types, no switch statements
- State mutations are direct (draft-based)
- Async operations use transactions with automatic rollback
- Resources handle caching, deduplication, and invalidation
From Zustand + React Query
| Zustand/React Query | StateMesh |
|---|---|
create() | createMesh |
useStore(selector) | useMeshSelector / useMeshState |
set() | mesh.setState / mesh.setPath |
useQuery | useMeshResource |
useMutation | useMeshMutation |
queryClient.invalidateQueries | mesh.invalidate(tags) |
| Persistence middleware | mesh.persist() |
Key differences:
- Single store for all state (client + server)
- No separate query client
- Built-in undo/redo, time travel, DevTools
From Jotai
| Jotai | StateMesh |
|---|---|
atom() | State paths |
useAtom | useMeshState |
atomFamily | Resources with params |
atomWithStorage | mesh.persist() |
atomWithObservable | mesh.resource() |
Key differences:
- Single store instead of distributed atoms
- Named actions and transactions
- Built-in middleware, guards, plugins
General Tips
TIP
StateMesh's mesh.action() is the closest equivalent to any mutation pattern. It's a named, typed function that receives a draft.
TIP
StateMesh's mesh.transaction() replaces both thunks and mutation hooks. It handles optimistic updates, rollback, retry, and timeout.
TIP
StateMesh's mesh.resource() replaces query hooks. It handles caching, deduplication, staleness, and invalidation.
Next Steps
- Getting Started — Install and set up StateMesh
- Core Concepts — Understand the mental model
