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.
YjsPresenceManager
Manages presence signaling, view/edit tracking, and session state for collaborative editing.
Tracks which documents you're viewing and editing, signals state to the server, and receives session updates with active participants.
Creating an instance
Use the same clientId and values as your .
connId
YjsDocumentManager
import { YjsPresenceManager } from "@stratasync/y-doc";const presenceManager = new YjsPresenceManager({ clientId: "client-abc-123", connId: "conn-xyz-456",});
PresenceManagerConfig
Property
Type
Description
clientId
string
Logical client identity for attribution.
connId
string
Connection-scoped identity for echo suppression and ownership.
Setting the transport
Set before signaling presence. See YjsDocumentManager for transport setup.
presenceManager.setTransport(yjsTransport);
Listens for session_state messages and sends doc_view and doc_focus messages.
API reference
startViewing
Signals that you opened a document.
import type { DocumentKey } from "@stratasync/y-doc";const docKey: DocumentKey = { entityType: "Task", entityId: "task-123", fieldName: "description",};presenceManager.startViewing(docKey);
Signature:startViewing(docKey: DocumentKey): void
Duplicate calls for the same document are ignored.
stopViewing
Signals that you closed a document. Auto-calls blur if editing.
presenceManager.stopViewing(docKey);
Signature:stopViewing(docKey: DocumentKey): void
focus
Signals editor focus. Auto-calls startViewing if not already viewing.
User opens document --> startViewing() --> doc_view "start" sent
User clicks editor --> focus() --> doc_focus "focus" sent
User clicks elsewhere --> blur() --> doc_focus "blur" sent
User closes document --> stopViewing() --> doc_view "stop" sent
The server aggregates signals into SessionState updates and broadcasts to all participants.