Skip to content

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.

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:

One vocabulary, either keyword

persist means "survives a reload" and ephemeral means "does not". Both are accepted on :state, :store, and :theme. The keyword only picks the default, and the token always means what it says. So these two counters behave identically, and each one states its intent on the line itself.

Persisted :state: 0, persisted :store: 0

Bump both, reload, and the pair comes back. Writing the token that already matches the default is redundant but never wrong, which is the point: a declaration you can read without remembering which keyword defaults which way.