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.
| Example | Main concept | Command |
|---|---|---|
| Quick Start | Core collaboration path | pnpm example:quick-start |
| Database Adapter | Persistence boundary | pnpm example:database-adapter |
| Permissions | Identity and authorization | pnpm example:permissions |
| History | Derived version history | pnpm example:history |
| Comments | Independent comments | pnpm example:comments |
| Worktree | Isolated editing and merge | pnpm example:worktree |
| Exchange | Office file exchange | pnpm example:exchange |
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.
pnpm example:quick-startOpen http://127.0.0.1:3010/?unit=quick-start-sheet&type=2.
Database Adapter
Compare custom Memory, PostgreSQL, and built-in SQLite Adapters. The implementations demonstrate
transactions, revision CAS, batch atomicity, and the customData transaction boundary.
pnpm example:database-adapterOpen http://127.0.0.1:3010/?unit=database-adapter-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 editor and read-only viewer.
pnpm example:permissionsOpen 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.
pnpm example:historyOpen 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.
pnpm example:commentsOpen 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.
pnpm example:worktreeOpen 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.
pnpm example:exchangeOpen http://127.0.0.1:3010/?unit=exchange-sheet&type=2. Import through File → Open (File) and
export through File → Save As.