How to use your Y.Doc on the server
Using @liveblocks/node, it’s possible
to retrieve your Yjs document and use it as a
Y.Doc on the server. This is often helpful
for retrieving text editor state, and we have some specific guides for this:
Getting your Y.Doc
Using
Liveblocks.getYjsDocumentAsBinaryUpdate
you can fetch your Yjs data, and place it inside a Y.Doc.
Note that any changes you make will not be applied to other users, as the
Y.Doc is not connected to any providers.
Applying changes
Should you wish to send any changes to your document to other users, you can
encode yDoc as a binary update, and use
Liveblocks.sendYjsBinaryUpdate
to apply the change.
These changes will be immediately applied to all connected users.