Playground

Change the inputs. Watch restate respond.

Seven experiments run the real package. The controller on the left belongs to this website; the example on the right only receives props, so its code shows exactly what you would write.

Controller — website onlyprops — the bridgeExample — the code you copy
01

Two screens, one store

Several components need the same value. Declare it once and read it anywhere.

What to watch
  • Press the step button: every reader shows the new number at the same time.
  • Change the number of readers: a new reader starts from the current value.

Preparing the example…

Get started
02

Render only what changed

A large store should not re-render every component on every change.

What to watch
  • Edit note: only the whole-store card renders.
  • Add item: items and summary render; the coupon card stays still.
  • Turn shallow off: the summary renders on every change, because its selector returns a new object each time.

Preparing the example…

Select only what you need
03

Many changes, one notification

Updating two stores one by one lets a subscriber see a half-finished state.

What to watch
  • Clear separately: the subscriber sees 0 items together with the old coupon.
  • Clear with batch: the subscriber runs once, after both stores changed.

Preparing the example…

Select only what you need
04

Save when you decide

Editing changes memory. Saving is an explicit action, and the status shows what is happening.

What to watch
  • Type: dirty turns on and nothing is written yet.
  • Raise the latency and save: operation shows save while the write runs.
  • Replay: the saved draft is restored from IndexedDB.

Preparing the example…

Save when you decide
05

Type fast, write once

Saving on every keystroke floods storage. autoSave waits for a pause.

What to watch
  • Type a sentence: edits climb quickly while writes grow by one after each pause.
  • Choose every change: each edit writes, but an edit back to the saved value writes nothing.

Preparing the example…

Save when you decide
06

Failure lab

Make storage slow, failing or unavailable, and watch restate keep your data and report the problem.

What to watch
  • Raise the latency and save three times: the requests share one write, so pending stays at 1 and all three results arrive together.
  • Turn on failing writes and save: dirty stays true and error shows the cause.
  • Make storage unavailable: saving rejects with STORAGE_UNAVAILABLE while editing keeps working.

Preparing the example…

Reliability by design
07

State per document

Each open document needs its own state, released when the document closes.

What to watch
  • Type in document A, then in B: each keeps its own text.
  • Close document A and open it again: it starts empty, because its scope was destroyed.

Preparing the example…

State owned by a component

Search docs

Search titles, descriptions and text of every guide.