Text editing
Sync supports collaborative text editing, merging simultaneous keystrokes character by character so multiple people, and AI agents, can edit the same documents without overwriting each other. There are two ways to add text editing: LiveText, the recommended choice for new applications, and Yjs, for editors that require the Yjs ecosystem.
For a full comparison, read the LiveText vs Yjs guide.
LiveText
When using LiveText for text
collaboration, it is a node in your Storage tree,
alongside LiveObject, LiveList, and LiveMap. Because text is part of the
same document as the rest of your collaborative data, you read and write to it
using the same APIs, plus edits share one undo history, and restoring a version
restores everything together.
Each LiveText currently has a 2 MB limit, which means Yjs is best
suited for documents that will grow very long. We’re working on improving this.
We recommend LiveText as the default choice for new applications that don’t
require long documents. It currently supports Tiptap, BlockNote, ProseMirror,
and CodeMirror—Tiptap is
our rich-text editor of choice.
Get started with LiveText
Yjs
When using Yjs for text collaboration, a
document is a Y.Doc that lives in the same room as your Storage data, but is
otherwise separate, with its own lifecycle, API, and binary format. In exchange
you get a large ecosystem of editor bindings—Slate, Quill, Monaco, SuperDoc, and
anything else built on Yjs—along with subdocuments and experimental offline
persistence.
We recommend Yjs when writing long documents, when your editor only has a Yjs binding.
Get started with Yjs
Supported editors
Some editors can be connected with either LiveText or Yjs, others only through their Yjs binding.
| Editor | With LiveText | With Yjs |
|---|---|---|
| Tiptap | @liveblocks/react-tiptap with collaborationMode: "liveblocks" | @liveblocks/react-tiptap |
| BlockNote | @liveblocks/react-blocknote with collaborationMode: "liveblocks" | @liveblocks/react-blocknote |
| Lexical | Not supported yet | @liveblocks/react-lexical |
| ProseMirror | @liveblocks/prosemirror | @liveblocks/yjs with y-prosemirror |
| CodeMirror | @liveblocks/codemirror | @liveblocks/yjs with y-codemirror.next |
| SuperDoc, Slate, Quill, Monaco, tldraw, other | Not supported yet | @liveblocks/yjs with the editor’s Yjs binding |
A few details worth knowing before you decide:
- For Tiptap and BlockNote, this is a single option on a package you’re already using. Comments, mentions, cursors, and toolbars work the same in either mode.
- Tiptap and BlockNote AI and experimental offline support currently require Yjs mode.
- Each
LiveTexthas a 2 MB limit, so Yjs is best suited for documents that will grow very long. We’re working on improving this.
Setting up LiveText
LiveText supports Tiptap,
BlockNote, ProseMirror, and CodeMirror.
Tiptap
To set up a collaborative Tiptap editor with LiveText, use
@liveblocks/react-tiptap and
pass
collaborationMode: "liveblocks".
Learn more about its features or read
the API reference under
@liveblocks/react-tiptap.
BlockNote
To set up a collaborative BlockNote editor with LiveText, use
@liveblocks/react-blocknote
and pass
collaborationMode: "liveblocks".
Learn more about its features or
read the API reference under
@liveblocks/react-blocknote.
ProseMirror
To set up a collaborative ProseMirror editor with LiveText, use
@liveblocks/prosemirror.
CodeMirror
To set up a collaborative CodeMirror editor with LiveText, use
@liveblocks/codemirror.
Learn more on the
@liveblocks/codemirror API
reference.
Setting up Yjs
To set up a collaborative text editor with Yjs, you need to connect a room and
fetch its Y.Doc. This is then passed to whichever editor you’re using.
Read the Yjs page for more details and
check @liveblocks/yjs for its API
reference.
Lexical
To set up a Lexical Yjs editor, the process is different, as we have a special package for it.
Learn more about its features or
read the API reference under
@liveblocks/react-lexical.