Realtime (Tier 3)
Live, multiplayer collaboration powered by Y.js — shared
text, arrays, and maps, plus presence (cursors, who’s here). Access via
sdk.realtime(docId).
Connect
Section titled “Connect”const doc = sdk.realtime('workspace');await doc.connect();Shared types
Section titled “Shared types”const text = doc.text('content'); // collaborative textconst list = doc.array('items'); // collaborative arrayconst meta = doc.map('metadata'); // collaborative map
text.insert(0, 'Hello');text.observe(() => render(text.toString()));
list.push([{ id: 1, name: 'Item' }]);list.observe(() => render(list.toArray()));Presence
Section titled “Presence”doc.presence.set({ user: { name: 'Alice', color: '#2161FF' }, cursor: { x: 100, y: 200 } });
doc.presence.subscribe(users => { for (const [clientId, state] of users) renderCursor(clientId, state.cursor);});Transactions & undo
Section titled “Transactions & undo”doc.transact(() => { list.push(['a']); list.push(['b']); });
const undo = doc.undoManager([text]);undo.undo();undo.redo();Events
Section titled “Events”on('status' | 'sync' | 'update', handler) — status is connecting,
connected, or disconnected. Clean up with doc.disconnect().
Manifest
Section titled “Manifest”<script type="shareout/manifest">{ "version": "2.0", "sources": { "realtime": ["workspace", "cursors"] } }</script>For structured but non-collaborative data, use tables instead.