Overview
getPageStore(StoreClass) get-or-creates a page store keyed by class. The creating component registers cleanup — when it unmounts, the registry entry is removed. Children calling the same class receive the existing instance.
createPageStore is a deprecated alias of getPageStore — prefer getPageStore in new code.
SSR: serializePageStore(instance) / serializeLivePageStore() emit typed field envelopes (atom / asyncAtom / asyncAction). buildPageStoreStateScript writes the transfer script. Hydrate applies snapshots; otherwise optional load() runs.
vs globalStore
|
API
|
Cleanup
|
Prefer when
|
|---|---|---|
getPageStore
| on creator unmount | Page/feature data that should die with the page. |
createGlobalStore
| survives nav | Shell/session state for the whole app session. |
getPageStore sharing
App and List share TodoStore. Adding an item updates both — same get-or-create instance.
Optional load()
Without a hydrate snapshot, load() seeds initial data once on create.