Y.Doc to the server via the existing WebSocket connection. This enables real-time collaborative editing with conflict-free resolution — no additional infrastructure required.
Editors can send Yjs document updates. Viewers can receive and apply Yjs updates, but outbound Yjs writes are blocked for viewer sessions.
Installation
The Yjs provider is exported from a separate entry point. You also needyjs as a peer dependency:
Import
Basic Usage
Constructor
An initialized and connected
CollabKitClient instance.A Yjs document instance.
Unique identifier for the CRDT document within the room. Multiple documents can coexist in the same room by using different IDs.
Properties
Events
synced
Fires when the initial document state has been loaded from the server:
Methods
destroy()
Disconnect the provider and clean up resources:
TipTap Integration
CollabKit’s Yjs provider works with TipTap and its collaboration extension:Disable TipTap’s built-in
history extension when using Collaboration. Yjs has its own undo/redo management.Multiple Documents
You can create multiple providers for different documents within the same room:How It Works
The Yjs provider uses CollabKit’s WebSocket connection to synchronize document state:- Initial sync: On creation, the provider sends a
crdtSyncRequestto the server, which returns the full document state. - Local changes: When the local
Y.Docis modified, the provider sends the delta as acrdtUpdatemessage. - Remote changes: The server broadcasts
crdtUpdatedmessages to all other clients, which the provider applies to the localY.Doc. - Persistence: The server stores the document state in its SQLite database. Documents survive server restarts.