PRO

Deno KV Realtime Sync

Multiplayer state sync over plain HTTP with no WebSocket infrastructure. Every table is one KV document: clients subscribe with GET /table/:name, whose SSE body is literally kv.watch().pipeThrough(TransformStream).pipeThrough(TextEncoderStream), so a client disconnect cancels the watch through stream teardown with no bookkeeping. Mutations POST the versionstamp the client last saw, and the write runs through kv.atomic().check() so concurrent editors get clean optimistic-concurrency conflicts (409 with the current state to rebase on) instead of silent lost updates, and every subscriber sees each committed change pushed live. Zero dependencies.

Install
npx shadcn@latest add https://ui.aryank.space/r/deno-kv-realtime-sync.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
mutate
Mutation
subscribers
unknown
if (cur.versionstamp !== m.expect) return conflict(); kv.watch([tableKey(name)])

Every table is one KV document streamed over SSE via kv.watch; a client disconnect cancels the watch through stream teardown, no bookkeeping.

Files

Dependencies
None.