Liveblocks is a realtime collaboration infrastructure for building performant
collaborative experiences. Follow the following steps to start adding
collaboration to your React application using the APIs from the
@liveblocks/react-blocknote
package.
Every Liveblocks package should use the same version.
liveblocks.config.ts
fileWe can use this file later to define types for our application.
Liveblocks uses the concept of rooms, separate virtual spaces where people
collaborate, and to create a realtime experience, multiple users must
be connected to the same room. Set up a Liveblocks client with LiveblocksProvider
, and join a room with RoomProvider
.
After setting up the room, you can add collaborative components inside it, using
ClientSideSuspense
to add loading spinners to your app.
Now that we set up Liveblocks, we can start integrating BlockNote and Liveblocks in the Editor.tsx
file.
To make the editor collaborative, we can add
useCreateBlockNoteWithLiveblocks
from @liveblocks/react-blocknote
.
To add Comments to your text editor, we need to import a thread composer
and list each thread on the page. Create a Threads.tsx
file that uses FloatingComposer
for creating new threads, alongside AnchoredThreads
and FloatingThreads
for displaying threads on desktop and mobile.
We can create some custom styles to position the editor and threads—import globals.css
, alongside the default Liveblocks styles. You can import them into the
root layout of your app or directly into a CSS file with @import
.
Text Editor is set up and working now, but each user is anonymous—the next step is to authenticate each user as they connect, and attach their name, color, and avatar, to their cursors and mentions.
Add your users to Text Editor
BlockNote is easy to extend, and a number of extensions are already available, making it possible to quickly create complex rich-text applications. Any additional features you add will be supported using Liveblocks.
Read the BlockNote docs
Congratulations! You now have set up the foundation for your collaborative BlockNote text editor inside your React application.
We use cookies to collect data to improve your experience on our site. Read our Privacy Policy to learn more.