Playground
Try bettersync live — two clients syncing through a virtual server
Try bettersync's sync protocol live in your browser. Two clients, one server, all running locally.
- Add items on either client
- Click Sync to push/pull changes through the server
- Watch HLC timestamps and tombstones in the log
Client A
node: aaaa · 0 items · 0 tombstones
No items yet
Client B
node: bbbb · 0 items · 0 tombstones
No items yet
Sync Log
Add items and sync to see the log
How does this work?
Each client maintains a Hybrid Logical Clock (HLC) that combines wall-clock time with a logical counter and a node ID. This ensures every change gets a globally unique, monotonically increasing timestamp.
When you sync, the client pushes local changes to the server and pulls remote changes. Conflicts are resolved with Last-Write-Wins (LWW) — the change with the higher HLC wins.
Tombstones track deletions. When Client A deletes an item, the tombstone prevents Client B from resurrecting it with a stale write.
This is exactly how bettersync works — but with real Postgres on the server and PGlite in the browser.
Try these scenarios
Basic sync
Add "Buy milk" on Client A, sync A, then sync B. The item appears on both.
Conflict resolution
Add "Draft v1" on Client A and "Draft v2" on Client B (same concept, different clients). Sync both. Last-Write-Wins — the higher HLC keeps its version.
Tombstone prevention
Add "Temp note" on Client A, sync both. Delete it on Client A, sync A. Now sync B — the tombstone prevents the deleted item from coming back.
Offline catch-up
Add several items on Client A without syncing. Add different items on Client B. Then sync both — all items merge correctly.