Examples

Run Collaboration SDK examples by capability and open each example's guide, Server entry point, and Web entry point.

All examples are located in the univer-collaboration-examples repository. Each example follows the same minimal web/main.ts + server/main.ts structure and runs independently. Complete Quick Start first, then select the example that matches the current integration task.

ExampleMain conceptCommand
Quick StartCore collaboration pathpnpm example:quick-start
Database AdapterBuilt-in and custom adapterspnpm example:database-adapter
PermissionsIdentity and authorizationpnpm example:permissions
HistoryDerived version historypnpm example:history
CommentsIndependent commentspnpm example:comments
WorktreeIsolated editing and mergepnpm example:worktree
File ServiceFile storagepnpm example:file-service
ExchangeOffice file exchangepnpm example:exchange
All UnitEvery capability togetherpnpm example:all-unit
Multi-nodeHorizontal scalingpnpm example:multi-node

Quick start

Assemble Collaboration Client, Transport, Endpoint, Service, and Memory Adapter. Use two browsers to verify HTTP loading, WebSocket sessions, the Room, ACK, and broadcast for the same Sheet.

Bash
pnpm example:quick-start

Open http://127.0.0.1:3010/?unit=quick-start-sheet.

Database adapter

Begin with the built-in SQLite Adapter, then replace it with the PostgreSQL Adapter or an Adapter of your own.

Bash
pnpm example:database-adapter

Open http://127.0.0.1:3010/?unit=persistent-sheet.

Permissions

Sign in as Bob (editor), Casey (viewer), or Dana (no document access) to compare what each user can read or change. Alice is the document creator. The server checks reads, room joins, and changeset submissions.

Bash
pnpm example:permissions

Open http://127.0.0.1:3010.

History

Add History Service, a separate Adapter, the History Endpoint, and the browser history entry, all outside Core. The Unit creation and changeset commit Events build History as a derived index that can be reconstructed.

Bash
pnpm example:history

Open http://127.0.0.1:3010/?unit=history-sheet, edit the Sheet, and select History at the top of the page.

Comments

Add Thread Comment Service, a separate Adapter, the Comment Endpoint, and the frontend comment entry. The Comment Endpoint reuses the sessions and Unit Rooms of the main collaboration Endpoint.

Bash
pnpm example:comments

Open http://127.0.0.1:3010/?unit=comments-sheet, select a cell, and use the comment entry.

Worktree

Follow the full lifecycle: an isolated draft, Ready, Reopen, and per-Unit Merge. Switch between trunk and draft to observe how Agent changes remain isolated until the merge.

Bash
pnpm example:worktree

Open http://127.0.0.1:3010/?unit=worktree-sheet&worktree=demo-worktree.

File service

Connect the File Service and File Endpoint. Images inserted into the Sheet are uploaded to the server, and the Unit data records only the file ID.

Bash
pnpm example:file-service

Open http://127.0.0.1:3010/?unit=file-service-sheet and insert an image through Insert → Image → Float Image.

Exchange

Assemble the Exchange Service and Exchange Endpoint for server-side Sheet import and export, task polling, and export at a confirmed revision.

Bash
pnpm example:exchange

Open http://127.0.0.1:3010/?unit=exchange-sheet. Import and export through the Import / Export toolbar above the editor.

All Unit

Combine all six Unit types, files, import and export, embedded attachments, comments, history, and print in a single application.

Bash
pnpm example:all-unit

Open http://127.0.0.1:3010 and switch Units in the sidebar.

Multi-node

Run two collaboration nodes behind Nginx. Redis relays realtime updates between the nodes and shares session tickets, so any node can serve any request. The example also requires Docker Compose and a License that covers two nodes.

Bash
pnpm example:multi-node

Open http://127.0.0.1:3010/ and select New Sheet to create a file. Copy the full URL into another tab to verify collaborative editing of the same document. Then create several more files and observe how they are distributed across the nodes.

Examples are not production applications

Fixed users, teaching authorization, Memory Adapters, local secrets, and in-memory task stores exist only for instruction. Identity, authorization, persistence, secrets, files, deployment, and product interaction remain the responsibility of the application.

How is this guide?

© 2026 DreamNum Co., Ltd.