G-counter live lab
Complexity IntermediateOpen one room across three tabs or devices. You control one hiker and compare the local notebooks as you exchange updates.
Create or join a room
Create a room, then open its link in two more tabs or on two other devices. The first three connections control the hikers; further connections observe.
The room service stores and shares cumulative counts. Your browser merges them through the G-counter kernel.
Enable JavaScript to connect to a live room.
Open room in another tab- AliceJoin to check
- BobJoin to check
- CarolJoin to check
Your browser's local notebooks
Your assigned notebook has the controls. The other two are local copies in this browser, not views into the other devices.
Merge rule Keep the largest bird count left by each hiker.
New note In transit to a checkpoint
Shared note Being delivered to the other hikers
Alice
Connected to checkpoint network
Local copy in this browser
Birds in this hiker's view
- No checkpoint note shared yet.
Bob
Connected to checkpoint network
Local copy in this browser
Birds in this hiker's view
Carol
Connected to checkpoint network
Local copy in this browser
Birds in this hiker's view
Count birds with Alice, Bob, or Carol, or leave Alice's and Bob's checkpoint notes together.
Optional: local delivery model
Speed, Jitter, and Auto-deliver affect delivery among the three copies in this browser. They do not pause the WebSocket connection or the server's storage. Rejoin to load the stored counts.
Run the worked example
Reset the sandbox and leave Alice's and Bob's notes together, or adjust how the notes travel.
Enable JavaScript to run the demo. The initial values and expected result remain available in the article.
Open the hikers' count tables
Each hiker's notebook has one row for Alice, Bob, and Carol. A row stores the largest count received from that hiker. Checkpoint notes can be delivered in any order.
| Hiker | Alice's view | Bob's view | Carol's view |
|---|---|---|---|
| Alice | 0 | 0 | 0 |
| Bob | 0 | 0 | 0 |
| Carol | 0 | 0 | 0 |
A repeated or older note cannot lower a row. Each hiker compares the note with the count already in the table and keeps the larger value.
Try a concurrent update
- Create a room. Open its link in two more tabs, or share the link with two other devices. Check that Alice, Bob, and Carol have connected.
- In Alice's tab, record +7. In Bob's tab, record +3. Make both changes before comparing the notebooks.
- From a reset count of 0, all copies should reach 10. Leave the room and join again to load the stored counts.
Reset clears the shared room for all connected hikers. An observer can read the room but cannot edit or reset it.
Storage and recovery
A Cloudflare Durable Object stores this room's shared data in a private SQLite database.
The server keeps the largest cumulative count for each hiker in one stored row. Rejoining restores those components; Reset clears them to zero.
Closing all tabs does not clear stored data. After a disconnect, rejoin to recover it. There is no persistent offline outbox or automatic reconnect; unconfirmed changes may be lost. Roles identify connections, not accounts. Anyone with the room code can join.
How multiplayer rooms work explains CRDT merging, DDS sequencing, storage lifetimes, and the example database records.