This example demonstrates using SuperDoc with Liveblocks as a cloud collaboration provider.
-
Get your Liveblocks API keys
- Create an account at liveblocks.io
- Get your public API key from the dashboard (starts with
pk_) - Get your secret API key for server-side room seeding (starts with
sk_)
-
Create
.envfilecp .env.example .env # Edit .env and add your keyAdd this manually for seeding:
LIVEBLOCKS_SECRET_KEY=sk_xxx
-
Install dependencies
npm install
-
Run the example
npm run dev
-
Open http://localhost:3000 in multiple browser tabs to test collaboration
This example includes a server-side seeding script that:
- Opens a DOCX with a headless SuperDoc editor.
- Generates a Yjs binary update.
- Ensures the room exists in Liveblocks.
- Sends the binary update with
sendYjsBinaryUpdate. - Verifies the room with
getYjsDocumentAsBinaryUpdate.
Run this exact seed command:
npm run seed -- /Users/nickjbernal/Desktop/justify-test.docxTo guarantee a brand-new room before seeding (delete if exists), use:
npm run seed -- --fresh /Users/nickjbernal/Desktop/justify-test.docxThen start the browser client and connect to the same room:
npm run devThis example also includes a small manual smoke test for the repo-local Python SDK.
It opens two SDK clients against the same Liveblocks room, inserts one line from
each client, verifies each client can read the other client's text, and saves the
resulting .docx so you can inspect it.
Build the local CLI once:
pnpm --prefix ../../../apps/cli run build:nativeSeed a room with a starting document:
npm run seed -- --fresh /absolute/path/to/test.docxRun the smoke:
npm run smoke:pythonThe output document is written to:
examples/collaboration/liveblocks/.superdoc-state/python-sdk-liveblocks-smoke.docxNotes:
smoke:pythonreadsexamples/collaboration/liveblocks/.envdirectly.- It uses the repo-local Python SDK source from
packages/sdk/langs/python. - It defaults to the repo-local CLI binary at
apps/cli/dist/superdoc. - Set
SUPERDOC_CLI_BINto override the CLI path. - Set
SMOKE_OUTPUT_DOCXto override the saved.docxpath.
Notes:
npm run seedreads.envvianode --env-file=.env.- Room id defaults to
VITE_ROOM_ID. You can override withLIVEBLOCKS_ROOM_ID. - Seeding requires
LIVEBLOCKS_SECRET_KEY(server-side key) and room id. - The script ensures the room exists (
getOrCreateRoom) before sending the update. --freshdeletes the room first, then reseeds it.- Optional: set
SEED_DOC_PATHin.envand runnpm run seedwithout CLI args.
import { createClient } from '@liveblocks/client';
import { LiveblocksYjsProvider } from '@liveblocks/yjs';
import * as Y from 'yjs';
// 1. Create client and enter room
const client = createClient({ publicApiKey: 'pk_...' });
const { room } = client.enterRoom('my-room');
// 2. Create Y.Doc and provider
const ydoc = new Y.Doc();
const provider = new LiveblocksYjsProvider(room, ydoc);
// 3. Pass to SuperDoc
new SuperDoc({
selector: '#superdoc',
modules: {
collaboration: {
ydoc,
provider,
},
},
});