Collaborative note editor demonstrating real-time sync between browser tabs.
- Text editing with Automerge CRDTs — every edit is a conflict-free operation that can be merged with edits from other peers
- Real-time sync via the browser's BroadcastChannel API — open two tabs and watch edits appear in both
- Custom capabilities — a
PubSubcapability for publishing and subscribing to changes, andcrux_kvfor persistent storage - Timed auto-save with
crux_time— edits are persisted after 1 second of inactivity
cd web-nextjsjust doctorto check you have the right toolsjust serveto start the dev server- Open the app in two browser tabs
- Type in one tab and watch the text appear in the other
The shared directory contains the Crux core with:
- Events for text editing:
Insert,Replace,MoveCursor,Select,Backspace,Delete - A
Notebacked by an Automerge document, supporting conflict-free merges - A custom
PubSubcapability (capabilities/pub_sub.rs) — the shell implements this usingBroadcastChannelto sync between tabs - A debounced save timer — edits are persisted to
crux_kvafter 1 second of inactivity - Tests covering editing, cursor management, save/load, and multi-peer sync
- NextJS —
web-nextjs/
Note: This example currently only has a web shell because the sync mechanism relies on
BroadcastChannel, which is a browser API. Native shells (iOS, Android) would need a different transport (e.g. WebSocket server) to demonstrate sync, and are not yet implemented.