Skip to content

Collaboration

Inkwell supports real-time collaborative editing via Yjs. Multiple users can edit the same document simultaneously with automatic conflict resolution and live cursors.

  • Live sync — changes appear instantly for all connected users
  • Remote cursors — each user’s cursor and selection is visible to others, color-coded by user
  • Scoped undo⌘Z only undoes your own changes, never edits from other users
  • Provider agnostic — works with any Yjs network provider

You own the Yjs document and network provider. Inkwell needs three things from you: the shared type, the awareness instance, and the local user’s info.

Terminal window
npm install yjs y-websocket
import * as Y from "yjs";
import { WebsocketProvider } from "y-websocket";
const doc = new Y.Doc();
const sharedType = doc.get("content", Y.XmlText);
const provider = new WebsocketProvider(
"wss://your-server.com",
"room-id",
doc,
);
import { InkwellEditor } from "@railway/inkwell";
function CollabEditor() {
return (
<InkwellEditor
content=""
collaboration={{
sharedType,
awareness: provider.awareness,
user: { name: "Alice", color: "#e06c75" },
}}
/>
);
}

When collaboration is provided, the Yjs document becomes the source of truth. The content prop is only used to seed an empty document on first load.

onChange still fires on local edits with the serialized Markdown. Use it for persistence:

<InkwellEditor
content=""
collaboration={config}
onChange={(md) => saveToDatabase(md)}
/>

Yjs supports many network providers. Inkwell works with all of them — you choose how documents sync.

ProviderProtocolUse case
y-websocketWebSocketSelf-hosted sync server
y-webrtcWebRTCPeer-to-peer, no server needed
LiveblocksManagedHosted infrastructure
FieldTypeDescription
sharedTypeY.XmlTextYjs shared type for the document. Create with doc.get("content", Y.XmlText).
awarenessAwarenessAwareness instance from your provider. Handles cursor sharing.
user.namestringDisplay name shown on remote cursors.
user.colorstringCursor and selection highlight color. Any CSS color value.