Collaborative Editing
Syncline Editor ships a full CRDT engine based on the RGA/YATA algorithm. Add a collab config block and remote cursors, selections, and peer presence are rendered automatically — no extra dependencies required.
Quick start
The fastest way to try collaboration is with LocalTransport, which syncs two editor instances on the same page without any server.
Transports
All three transports implement the same CRDTTransport interface, so you can swap them without changing any other code.
| Transport | Scope | Server needed? | Typical use |
|---|---|---|---|
LocalTransport | Same page | No | Split-view demos, in-page diffing, tests |
BroadcastChannelTransport | Same origin, cross-tab | No | Cross-tab sync, offline-first apps |
WebSocketTransport | Any device / network | Yes (any WS relay) | Production multi-user editing |
LocalTransport — same page
Fastest option. Both editor instances share a simple in-memory broadcast bus keyed by the room string. Ideal for split-view demos and automated tests.
BroadcastChannelTransport — cross-tab
Uses the browser BroadcastChannel API (same origin) to sync edits across multiple tabs and windows — no server required. Works in all modern browsers.
WebSocketTransport — cross-device
Connect to any WebSocket relay (your own server or a hosted one). The transport handles reconnections automatically: the CRDT state vector ensures no operations are lost after a reconnect.
Dynamic connect / disconnect
You can enable, swap, or disable collaboration at any time on an existing editor instance using editor.updateConfig().
CollabConfig reference
AwarenessState shape
The map passed to onPeersChange contains one entry per connected peer (excluding the local user). Each value is an AwarenessState:
The color field is deterministic — it is derived from the peer's site ID so it stays stable across reconnects and page reloads.
How it works
Algorithm: Each character is represented as a CRDT node with a globally unique ID (site + clock). Insertions use YATA tie-breaking, and deletions are tombstoned — guaranteeing convergence with no central authority.
State vectors: Each peer tracks a state vector (logical clock per site). On reconnect, only the missing operations are exchanged, keeping reconnection bandwidth minimal.
Awareness: Cursor and selection positions are broadcast as ephemeral awareness messages — they are not part of the persistent CRDT document and do not increase document size over time.
© 2026 Syncline Editor. All rights reserved.