restate / v1.0.0

Frequently asked questions

Answers to common questions about rendering, saving, scopes and errors in restate.

BasicsDo I need a Provider?

No. A store is a module-level value; any component that imports it can use it. Use useRestateScope when state should belong to one component instance.

BasicsWhy does my component render on every change?

Calling the hook without a selector subscribes to the whole value. Pass a selector that returns only what the component shows.

BasicsMy selector returns an object and renders every time.

A new object is never Object.is-equal to the previous one. Pass shallow as the second argument, or select the fields separately.

BasicsI changed an object but nothing updated.

set received the same object, so restate saw no change. Return a new object or array from set.

SavingWhere do I wait for saved data?

Once, at the client entry: await restateManager.ready before rendering the app. Components then read saved values directly. Stores in a useRestateScope wait for their own scope.manager.ready.

SavingWhen is data written to storage?

Only when you call save(), or after changes when autoSave is on. Editing changes memory; status().dirty tells you there are unsaved changes.

SavingShould I use autoSave or save()?

Use autoSave for settings and drafts that should always persist. Use save() when the user decides, such as a Save button or a form submission. You can call save() even with autoSave on, for example on pagehide.

SavingSaving fails in a private window or during SSR.

When storage is unavailable the store keeps working in memory, status().available is false and save() rejects with STORAGE_UNAVAILABLE. Startup still succeeds.

ErrorsrestateManager.ready rejected. What now?

It rejects with BULK_OPERATION_FAILED when a record could not be read, migrated or validated. error.failures names each store and its error. Fix or clear the record, call that store’s initialize(), and access ready again.

ErrorsI see QUEUE_FULL or STORAGE_TIMEOUT.

Storage is slower than the work you queue. Avoid calling save() in a tight loop — a waiting save already takes the newest value — or use autoSave with a delay. Tune maxPendingOperations and operationTimeoutMs if needed.

ErrorsA late request writes to a store after unmount.

set() and reset() on a destroyed store are ignored, like a React state update after unmount. Subscribing throws STORE_DESTROYED and storage commands reject.

ScopesMy scoped store ignores new props.

The factory runs once, like a useState initializer. Render the component with a key for each document so a new document gets a new scope.

ScopesHow do I avoid hydration mismatches?

Pass the same server data as props on the server and the client, and create the store from it in useRestateScope. The initial value becomes the server snapshot.

ScopesWhy is my scoped store not in restateManager.ready?

Scoped saved stores start loading after the owning component commits on the client. Wait for scope.manager.ready in a loading boundary inside that component.

SavingMMKV_UNAVAILABLE on React Native.

Install react-native-mmkv and its native dependencies, then rebuild the app. In Expo, use a development build. Memory stores work without MMKV.

Search docs

Search titles, descriptions and text of every guide.