createStore creates a Zustand store synced with the view’s persisted state, on the same lifecycle as useViewState. Reach for it when state is complex or shared across components; otherwise use useViewState.
Example
A counter store persists itscount across remounts, and the view reads and updates it through the store hook.
Signature
Parameters
storeCreator
(set, get) => ({ ... }) returning the store’s initial state and actions.
defaultState
Returns
useCounter((s) => s.count)), or use getState, setState, and subscribe outside React. Store updates persist to the view’s state, and external state changes rehydrate the store.
useViewState
The simpler hook this builds on, and its lifecycle
Manage State
Decide what to persist and share with the model
DataLLM
Narrate the on-screen state to the model