@docx-editor.dev/pro/vue/webrtc

@docx-editor.dev/pro/vue/webrtc — Vue composable that owns a WebRTC room.

Import this subpath only when you use WebRTC. @docx-editor.dev/pro/vue does not load a network provider.

Functions (1)

useWebrtcCollaborationfunctionSource ↗

Own a WebRTC collaboration room for a Vue host.

The default Pro Vue entry does not import this composable. Import it from @docx-editor.dev/pro/vue/webrtc so a review-only bundle does not load a network provider.

declare function useWebrtcCollaboration(options?: MaybeRefOrGetter<UseWebrtcCollaborationOptions | null>): UseWebrtcCollaborationReturn;

Interfaces (5)

CollaborationIdentityUpdateinterfaceSource ↗

Display-identity fields a live session can update.

actorId and role are attribution and stay immutable for the session lifetime, so this type cannot name them.

interface CollaborationIdentityUpdate
MemberTypeSummary
color?stringNew presence color, at most 64 characters.
name?stringNew display name, 1 to 256 characters after trimming.

CollaborationSessioninterfaceSource ↗

Host-facing collaboration session.

A host reads identity, status, presence, and undo. The editor attaches [EditorCollaborationSession](EditorCollaborationSession) internally and never through this type.

interface CollaborationSession
MemberTypeSummary
canRedoWhether the shared undo history holds a local step to redo.
canUndoWhether the shared undo history holds a local step to undo.
documentIdstringThe room's document id.
identityCollaborationIdentityThe validated local identity.
offlineEditing?booleanWhether edits continue while the transport is down (`disconnected`). Set by the `offlineEditing` option; absent means true.
participantsParticipants in presence, this replica included. Capped at 256.
redoRedo this participant's last undone step. Returns false when refused.
remoteSelectionsOther participants' selections, resolved into this replica's addresses.
sessionIdstringUnique identity for this attachment lifetime.
setIdentityUpdate the display name and color mid-session, when the replica supports it.
statusCurrent lifecycle state.
statusSnapshotCached status, current reason, and last failure.
subscribeParticipantsCall `listener` when the participant list changes. Returns the unsubscribe function.
subscribeRemoteSelectionsCall `listener` when a remote selection changes. Returns the unsubscribe function.
subscribeStatusCall `listener` on each status or reason change. Returns the unsubscribe function.
undoUndo this participant's last step; others' edits stay. Returns false when refused.

UseWebrtcCollaborationConnectOptionsinterfaceSource ↗

Arguments for [UseWebrtcCollaborationReturn.connect](UseWebrtcCollaborationReturn.connect).

interface UseWebrtcCollaborationConnectOptions
MemberTypeSummary
bootstrapUseWebrtcCollaborationBootstrapWhether to seed the room, join it, or let the peers decide.
iceServers?readonly RTCIceServer[]STUN and TURN servers for the peer connections. Pass TURN servers in production.
identityCollaborationIdentityThe local participant. Recorded as the author of this replica's changes.
offlineEditing?booleanAdmit local edits while the transport is `disconnected`. Buffered updates merge on reconnect. On by default; pass `false` to pause editing while disconnected. See [CreateDocumentCollaborationOptions.offlineEditing](CreateDocumentCollaborationOptions.offlineEditing).
password?stringSignaling encryption key. Every peer passes the same value.
roomIdstringRoom id shared by every peer. Make one with `createCollaborationRoomId`.
signaling?readonly string[]Signaling server URLs. Omitted, the room uses the public demo endpoints and warns once.

UseWebrtcCollaborationOptionsinterfaceSource ↗

Input for [useWebrtcCollaboration](useWebrtcCollaboration).

interface UseWebrtcCollaborationOptions
MemberTypeSummary
modules?readonly EditorModule[]Host modules. The hook adds `collaborationModule` when a room is ready. A host collaboration contribution is a configuration error and throws.
room?UseWebrtcCollaborationConnectOptions | nullConnect this room when the composable starts. Omit it and call [UseWebrtcCollaborationReturn.connect](UseWebrtcCollaborationReturn.connect) after the user chooses a room. A different room, server, bootstrap kind, or `actorId` leaves the old room and connects the new one, and `null` leaves. A room opened with `connect` stays.

UseWebrtcCollaborationReturninterfaceSource ↗

Values [useWebrtcCollaboration](useWebrtcCollaboration) returns.

interface UseWebrtcCollaborationReturn
MemberTypeSummary
connect(options: UseWebrtcCollaborationConnectOptions) => Promise<CollaborationFailure | null>Connect a room. RESOLVES with the failure, or null on success — it does not reject.
documentReadonly<Ref<Uint8Array | null>>The room's document as `.docx` bytes to mount. Null until the room is ready.
errorReadonly<Ref<CollaborationFailure | null>>The connect failure or session failure, or null. Check it before `document`.
leave(nextDocument: Uint8Array) => voidDestroy the room and carry on editing locally.
modulesReadonly<Ref<readonly EditorModule[]>>Modules to pass to the editor. They include the collaboration module once ready.
pendingReadonly<Ref<boolean>>True while a connect is in progress.
providerReadonly<Ref<WebrtcProvider | null>>The owned `y-webrtc` provider. Null while no room is connected.
rejoin(nextDocument: Uint8Array) => Promise<CollaborationFailure | null>Recover a session that reached status `error`: leave with `nextDocument`, then connect again to the same room with the same identity, signaling, and password.
sessionReadonly<Ref<CollaborationSession | null>>The live session for status and presence. Null while no room is connected.
unsyncedChangesReadonly<Ref<number>>Local changes no peer has received: made while no peer was connected, and not synced since. A WebRTC room has no server, so these changes exist only in this browser, and closing the page loses them. Warn before the page closes while it is above zero.
ydocReadonly<Ref<Y.Doc | null>>The room's shared Yjs document, owned by the composable. Null while no room is connected.

Type aliases (1)

UseWebrtcCollaborationBootstraptypeSource ↗

Bootstrap for one WebRTC room.

type UseWebrtcCollaborationBootstrap = CollaborationBootstrap;