AI agents: fetch the documentation index at llms.txt. Markdown versions are available by appending .md to any page URL, including this page's markdown.
Collaborative editing hooks
React hooks for Yjs collaborative document editing and presence management.
Integrate Yjs CRDT documents with React components. Requires the yjs peer dependency and a configured Yjs transport.
interface DocumentKey { entityType: string; // Model name, such as "Task" entityId: string; // Model ID, such as "task-123" fieldName: string; // Field name, such as "description"}
UseYjsDocumentOptions
Option
Type
Default
Description
initialContent
string
-
Initial content if the document is empty.
autoConnect
boolean
false
Automatically connect when the component mounts.
editing
boolean
-
Start in editing mode (signals presence).
skip
boolean
false
Skip connecting entirely.
UseYjsDocumentResult
Field
Type
Description
doc
YDoc | null
The Yjs document instance. null before connection.
connectionState
YjsConnectionState
"disconnected", "connecting", "syncing", or "connected".
trackVisibility: viewing starts when visible (intersection ratio > 0.1) and stops when leaving the viewport. trackFocus: editing starts on focusin and stops on focusout.