Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tldraw/tldraw/llms.txt
Use this file to discover all available pages before exploring further.
Multiplayer overview
The tldraw multiplayer system enables real-time collaboration through WebSocket-based synchronization. Multiple users can work on the same canvas simultaneously with automatic conflict resolution, live cursors, and presence awareness.Architecture
The sync system uses a client-server architecture with three main components:- Client:
TLSyncClientmanages local state and bidirectional sync with the server - Server:
TLSyncRoomacts as the authoritative source and broadcasts changes - Storage: Pluggable storage layer for persistence (in-memory, SQLite, or custom)
How it works
The synchronization follows a git-like push/pull/rebase model:Local changes
When you make changes locally, they’re immediately applied to your store for responsive UI
Key features
Real-time synchronization
Changes are synchronized at 30 FPS when collaborating, dropping to 1 FPS when working solo to conserve bandwidth.Presence awareness
See live cursors, selections, and viewport positions of other users. The presence system operates independently from document synchronization.Conflict resolution
Automatic conflict resolution ensures consistency across all clients. The server acts as the source of truth.Optimistic updates
Local changes are applied immediately for responsiveness, then reconciled with the server asynchronously.Schema migrations
Built-in support for schema versioning allows clients on different versions to collaborate safely with automatic down-migrations.Packages
The multiplayer system is split across two npm packages:@tldraw/sync
React hooks and utilities for client-side multiplayer:@tldraw/sync-core
Core synchronization primitives for both client and server:Connection states
The sync client progresses through several states:| State | Description |
|---|---|
loading | Establishing connection and loading initial state |
synced-remote | Connected and actively synchronizing |
error | Connection failed or sync error occurred |
Protocol
The sync protocol uses WebSocket messages with the following event types: Client → Server:connect- Initial handshake with schema and protocol versionpush- Send local changes to serverping- Keep-alive message
connect- Connection acknowledgment with initial statepatch- Document changes to applypush_result- Acknowledgment of client push (commit, discard, or rebase)pong- Keep-alive responsedata- Batched data messages for efficiency
Next steps
Quick start
Get multiplayer running in 5 minutes
Setup guide
Detailed setup instructions
Client API
Client-side API reference
Server API
Server-side API reference