Product updates

Introducing Liveblocks Yjs

Today, we’re excited to announce Liveblocks Yjs, a fully managed, highly scalable real‑time data store for Yjs documents. Powered by Yjs, it’s optimized for building collaborative text editors such as Google Docs.

Picture of Steven Fabre
Steven Fabre
@stevenfabre
Introducing Liveblocks Yjs

Today, we’re excited to announce Liveblocks Yjs, a fully managed, highly scalable real-time data store for Yjs documents. After months of close collaboration with design partners, it is now available in beta for everyone.

With this update, Liveblocks now offers two serverless data stores for collaborative documents: Liveblocks Storage and Liveblocks Yjs. While Liveblocks Storage is optimized for building multiplayer creative tools, Liveblocks Yjs enables you to build and ship collaborative text editors like Notion and Google Docs in a matter of days. Below is an open‑source example built with Liveblocks Yjs.

Loading
Loading

What is Yjs you may ask? It’s an open-source CRDT framework created by Kevin Jahns that has grown to be the preferred way for developers to build collaborative rich text editors. It comes with powerful features such as multiplayer undo/redo, lazy loading subdocuments, and offline support. And thanks to its incredible community, Yjs already has integrations with the most popular open-source text and code editor frameworks out there: Lexical, Tiptap, Slate, Quill, CodeMirror, Monaco, and more.

The challenge though is that the decentralized nature of Yjs makes it difficult to scale for production applications. Since all updates get stored, Yjs documents tend to get big really fast. Plus, the raw Yjs data requires some heavy engineering lifting to be dealt with.

That’s why we’ve created Liveblocks Yjs, the world’s most advanced platform for building, hosting, and scaling Yjs applications. No configuration, no maintenance required.

Supercharged Yjs developer experience

It’s fair to say that developer experience is close to our heart so it was important to us that Yjs integrated seamlessly into the Liveblocks ecosystem you’re already used to: dashboard, DevTools, webhooks, REST API, and more.

A centralized hub for Yjs documents

Enable anyone on your team to view, inspect, and manage, stored Yjs documents from the Liveblocks dashboard.

Yjs documents in the Liveblocks dashboard

Yjs triggered webhook events

Webhook events are triggered as users edit Yjs documents, enabling you to automatically perform custom actions in your back end, such as sending notifications, saving your data to a database, or indexing for search.

Yjs webhook events - YDocUpdatedEvent

Interact with Yjs documents via REST API

The Liveblocks REST API enables you to retrieve and update Yjs documents. Ideal for syncing data with your own system.

https://api.liveblocks.io/v2/rooms/{roomId}/ydochttps://api.liveblocks.io/v2/rooms/{roomId}/ydoc-binary

Hosted on a robust and highly scalable WebSocket infrastructure

Liveblocks Yjs runs on a WebSocket infrastruture where Yjs documents are stored in edge regions close to your users, reducing latency and improving end-user performance while enabling you to scale effortlessly. Liveblocks also manages awareness and WebSocket connections automatically, so you don’t have to.

Liveblocks WebSocket infrastructure

Getting started

Today, all users can get started with Liveblocks Yjs by using @liveblocks/yjs, our Yjs provider.

$npm i @liveblocks/yjs

This is how to set up your Yjs provider in JavaScript—attach this to your chosen editor to enable multiplayer.

import { createClient } from "@liveblocks/client";import LiveblocksProvider from "@liveblocks/yjs";import * as Y from "yjs";
const client = createClient({ publicApiKey: "sk_prod_xxxxxxxxxxxxxxxxxxxxxxxx",});
// Get this with `useRoom` in Reactconst room = client.enter("your-room-id", { initialPresence: {} });const doc = new Y.Doc();
const provider = new LiveblocksProvider(room, doc);

Start with a guide

We recommend you start with a guide. We’ve written specific guides for each popular text and code editor.

We also have some more advanced Yjs guides focused around building more features into your app.

Try our examples

Along with our guides, we now have open-source examples for each editor, including the live demo posted in this article.

You can also try the Liveblocks Starter Kit for Next.js which now includes a collaborative text editor powered by Liveblocks Yjs.

Moving forward

We wouldn’t be here without the awesome work from Kevin Jahns and the Yjs community. Liveblocks is now a sponsor, and we’ll continue to invest in Yjs, furthering our aim of connecting people together, and building a more collaborative web.