One API, two modes
A StoreValue is a plain in-memory value until it isn't. Bind a doc and the same handle becomes a CRDT — reads stay synchronous, writes stay a method call.
Write it like in-memory state. Get real-time collaboration, offline persistence, and undo/redo — opt-in, behind the same API.
import { StoreValue } from "@super-store/store"
// Local — identical to an in-memory store:
const counter = new StoreValue(0)
counter.subscribe(() => render(counter.getSnapshot()))
counter.set(1) // renders 1
// Collaborative — same handle, opt-in:
counter.onUpdate((u, { local }) => local && bus.send(u))
bus.on("message", (u) => counter.applyUpdate(u))yjs import Each grid below is its own StoreValue, backed by its own document — not shared state. Toggle a cell: your edit travels as CRDT bytes and merges into the other. Edit both at once; concurrent changes to different cells each win.