Global store
:store is durable, page-global state. It persists to localStorage under the
wd:store: prefix, rehydrates on load, and syncs across tabs through the
storage event — no backend, no wiring. Add ephemeral to opt a store out of
persistence entirely.
A durable cart
This cart is a :store, so it survives a full reload and mirrors into every open
tab. Add a couple of items, refresh the page, and the count holds.
Cart: 0
— $
The cart is empty. Add something, then reload — it stays.
The cart is empty. Add something, then reload — it stays.
Reset cart runs -> cart reset, which restores the declared seed ([]),
not the last persisted value — and writes that seed back to storage.
An ephemeral draft
:store draft = "" ephemeral is in-memory only. It is bound two-way to the
input and echoed below, but nothing reaches localStorage, so a reload wipes it
clean.
Draft says: