Collaboration integration

Connect the Univer editor to a collaboration service so users can edit the same document.

Collaboration connects browser editors to one shared document service. When two users open the same spreadsheet, an edit in one browser appears in the other.

Set up the backend first through server integration. The editor configuration and document loading described below follow it. The paired Server and Web code is in Collaboration Quick Start.

100%

Connect your existing editor

A different editor is not required. Retain the existing Web SDK editor and follow the browser configuration in Quick Start to add the collaboration plugins, then configure document loading, edit submission, and the WebSocket address. Browser and server package versions must remain compatible.

The fixed example users and default permissions are intended for demonstration. In an application, send login credentials with each request so the backend can verify identity and document access. Licensing is covered under license configuration.

Plugin configuration

Batching and retry timeouts

UniverCollaborationClientPlugin

  • socketService
    Ctor<ICollaborationSocketService>
    Selects the socket implementation used by the current runtime.
  • sendChangesetTimeout
    numberDefault: 2000 ms
    Sets how long local edits are buffered before they are sent.
  • changesetAckTimeout
    numberDefault: 20000 ms
    Sets how long to wait for an acknowledgement before retrying.
  • maxChangesetAckTimeout
    numberDefault: 120000 ms
    Sets the upper bound on the interval between resends.

The batching delay and the acknowledgement timeout are separate timers. The client plugin defaults to sendChangesetTimeout: 2000, changesetAckTimeout: 20000, and maxChangesetAckTimeout: 120000, all in milliseconds. The submission request uses the acknowledgement timeout as well. Changesets that are never acknowledged are resent with exponential backoff, capped at the maximum. Setting the acknowledgement timeout and the maximum timeout to the same value produces a constant interval.

TypeScript
import { UniverCollaborationClientPlugin } from '@univerjs-pro/collaboration-client'import { BrowserCollaborationSocketService } from '@univerjs-pro/collaboration-client-ui'univer.registerPlugin(UniverCollaborationClientPlugin, {  socketService: BrowserCollaborationSocketService,  sendChangesetTimeout: 200,  changesetAckTimeout: 20_000,  maxChangesetAckTimeout: 120_000,})

Add these options to the existing client registration and keep its socket and endpoint configuration. The Sheets and Docs collaboration presets use a 200 ms batching delay and do not expose the acknowledgement timeout options, so customizing these timeouts requires plugin mode.

Conflict recovery notices

UniverCollaborationClientUIPlugin

  • enableDefaultConflictUI
    booleanDefault: true
    Shows the built-in conflict recovery notices.
TypeScript
import { UniverCollaborationClientUIPlugin } from '@univerjs-pro/collaboration-client-ui'univer.registerPlugin(UniverCollaborationClientUIPlugin, { enableDefaultConflictUI: false })

Preset configuration

UniverSheetsCollaborationPreset / UniverDocsCollaborationPreset

  • enableDefaultConflictUI
    booleanDefault: true
    Shows the built-in conflict recovery notices.
TypeScript
import { UniverSheetsCollaborationPreset } from '@univerjs/preset-sheets-collaboration'const collaborationPreset = UniverSheetsCollaborationPreset({ enableDefaultConflictUI: false })
TypeScript
import { UniverDocsCollaborationPreset } from '@univerjs/preset-docs-collaboration'const collaborationPreset = UniverDocsCollaborationPreset({ enableDefaultConflictUI: false })

By default, the UI shows a conflict notice that names the reason. The notice offers a reload after cache cleanup succeeds, and a retry if cleanup fails. To run the recovery flow in the application, set enableDefaultConflictUI: false in the existing initialization and handle the event directly.

Add the collaboration presets to the existing createUniver({ presets: [...] }) call, next to the editor preset, and keep the endpoint and history settings. See event payloads and client configuration.

Create and open the same document

Creating a document and opening one are separate actions:

  1. When a user creates a document, the backend saves it and returns its ID.
  2. The browser loads that ID. Reuse the same ID when the document is reopened or shared with another user.

The API names the document ID unitId. Do not create a new local blank document on every visit.

Set the current user before loading a document. The current user identifies the collaborator and owns the local offline cache; see Identity and authorization.

For example, after the Sheets and collaboration plugins are registered, load a spreadsheet from the server:

TypeScript
import { UserManagerService } from '@univerjs/core'import '@univerjs-pro/collaboration-client/facade'univer.__getInjector().get(UserManagerService).setCurrentUser({ userID, name, avatar })const workbook = await univerAPI.getCollaboration().loadSheetAsync('your-document-id')if (!workbook) throw new Error('Document could not be loaded')

Product-specific loading is covered in the Sheets, Docs, Slides, Boards, Bases, and PDFs guides. Confirm that the product and the backend release you target support the feature.

Verify synchronization, saving, and permissions

Open the same document in two independent browser sessions, such as a regular window and a private one. Edit in one session and check what the other shows. Then reload the page, reconnect, restart the server, and confirm that the content is still present.

Test as an editor, a viewer, and a user with no access. Read-only UI settings only control what the page permits; the server must still reject unauthorized reads and changes.

If documents load but edits do not synchronize, check the WebSocket connection. If content disappears after a restart, check backend storage. Those settings belong to server integration.

Add exchange, comments, or history

To edit an imported file jointly, create a collaborative document from its converted data; see file exchange integration. Comments and history each require their own plugins, services, and permissions; follow Office extension modules.

For history panel configuration, see the Sheets, Docs, Slides, Boards, and Bases guides. See PDFs history for what it covers today.

Synchronization status and retries

Import the collaboration Facade before registering listeners. CollaborationStatusChanged reports the current status of every unit already collaborating when the listener is registered, then reports changes without repeating consecutive identical statuses. hasWritePending(unitId) covers queued edits, edits awaiting acknowledgement, and offline edits. If the ID is omitted, it checks the focused unit. A connected socket does not mean the edits are saved.

TypeScript
import '@univerjs-pro/collaboration-client/facade'const collaboration = univerAPI.getCollaboration()const statusSubscription = univerAPI.addEvent(univerAPI.Event.CollaborationStatusChanged, (event) => {  console.info(event.unitId, event.status, collaboration.hasWritePending(event.unitId))})const resendSubscription = univerAPI.addEvent(univerAPI.Event.CollaborationChangesetResend, (event) => {  console.info(event.unitId, event.reason, event.attempt, event.unsyncedMutationCount, event.nextDelayMs)})

CollaborationChangesetResend fires on resends, not on the first submission. The reasons are ack_timeout, request_failed, license_editing_connections_exceeded, should_retry, and reconnect; attempt, elapsedMs, unsyncedMutationCount, and nextDelayMs provide the data needed for a saving or retrying indicator. Dispose the event subscriptions when the editor is removed.

request_failed means a retryable request failure, such as a network error or an HTTP 408, 429, or 5xx response. license_editing_connections_exceeded means the licensed editing connections are all in use and the server requested a resend.

Handle conflicts in the host

CollaborationConflict fires once when a unit enters conflict, after the offline-cache cleanup attempt. Register the listener before loading any documents. Its reason is transform_failed, apply_failed, changeset_rejected, license_unit_type_rejected, permission_rejected, or remote_revert; message and revert provide additional detail when available.

license_unit_type_rejected means the server license does not cover collaboration on this document type.

TypeScript
import type { IEventParamConfig } from '@univerjs/core/facade'import '@univerjs-pro/collaboration-client/facade'const conflicts = new Map<string, IEventParamConfig['CollaborationConflict']>()const conflictSubscription = univerAPI.addEvent(univerAPI.Event.CollaborationConflict, (event) => {  conflicts.set(event.unitId, event)})

The example retains the event for a host recovery screen. The map lives only in memory, so the application must save or export any localChanges before a refresh. This event is the only opportunity to retain them; cache data that has already been cleared cannot be recovered by a later read. awaitingChangeset may already have been applied on the server, so it should not be replayed blindly.

cacheCleared: false means a refresh would replay the old cached edits, so cache cleanup must be resolved before refreshing. Clearing the cache does not mean the unsynchronized edits were saved. A permission_rejected conflict also requires resolving access; reloading does not grant permission.

Server reasons and license notices

When the server rejects a change, CollaborationConflict.message carries the reason the server gave, if it gave one. Do not parse localized message text to decide the recovery action; branch on reason instead. license_unit_type_rejected requires a server license that covers the document type, while license_editing_connections_exceeded is a resend signal: the edits remain unacknowledged and keep retrying. Keep the editor open until hasWritePending(unitId) becomes false or the application has retained the edits.

The default UI displays an editing-capacity notice and, on a resend at least 20 seconds after the first send, a save-timeout notice. These are removed when the unit leaves the awaiting states or is disposed. A domain rejection has a dedicated notice as well. enableDefaultConflictUI: false disables conflict recovery notices only; it does not disable these waiting or domain notices.

How is this guide?

© 2026 DreamNum Co., Ltd.