Examples

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

All examples live in univer-collaboration-examples. They use the same minimal web/main.ts + server/main.ts shape and run independently. Complete Quick Start first, then choose another example based on your integration task.

ExampleMain conceptCommand
Quick StartCore collaboration pathpnpm example:quick-start
Database AdapterDatabase adapterspnpm example:database-adapter
PermissionsIdentity and authorizationpnpm example:permissions
HistoryDerived version historypnpm example:history
CommentsIndependent commentspnpm example:comments
WorktreeIsolated editing and mergepnpm example:worktree
ExchangeOffice file exchangepnpm example:exchange
Multi-nodeDocument-based multi-node routingpnpm example:multi-node

Quick Start

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

Bash
pnpm example:quick-start

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

Database Adapter

Demonstrate how to use the built-in SQLite Adapter and implement a custom Database Adapter.

Bash
pnpm example:database-adapter

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

Permissions

Create trusted identity from a cookie and protect Unit HTTP reads, realtime JOIN, and changeset submission separately. The page switches between a teaching Alice · Editor and read-only Bob · Viewer.

Bash
pnpm example:permissions

Open http://127.0.0.1:3010.

History

Add History Service, a separate Adapter, History Endpoint, and the browser history entry outside Core. Unit creation and changeset commit Events build History as a reconstructable derived index.

Bash
pnpm example:history

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

Comments

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

Bash
pnpm example:comments

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

Worktree

Demonstrate the complete isolated draft, Ready, Reopen, and per-Unit Merge lifecycle. Switch between trunk and draft to see how Agent changes remain isolated before merge.

Bash
pnpm example:worktree

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

Exchange

Compose @univerjs-pro/exchange-node with Collaboration Service for server-side Sheet import and export, task polling, snapshot import, and confirmed-revision export.

Bash
pnpm example:exchange

Open http://127.0.0.1:3010/?unit=exchange-sheet&type=2. Import through File → Open (File) and export through File → Save As.

Multi-node

Distribute collaboration workloads for different documents across multiple server nodes to reduce the load on each node and increase overall concurrency.

Bash
pnpm example:multi-node

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

Examples are not production applications

Fixed users, teaching authorization, Memory Adapters, local secrets, and in-memory file and task stores exist only for instruction. The application still owns identity, authorization, persistence, secrets, files, deployment, and product interaction.

How is this guide?

© 2026 DreamNum Co., Ltd.