Get started with a Tiptap text editor using Liveblocks and React

Liveblocks is a realtime collaboration infrastructure for building performant collaborative experiences. Follow the following steps to start adding collaboration to your React application using @liveblocks/react-tiptap with LiveText backed by Liveblocks Storage.

Beta

The Tiptap LiveText integration is currently in beta, and LiveText documents are limited to 2 MB. Read the LiveText vs Yjs guide to compare both approaches.

Quickstart

  1. Install Liveblocks and Tiptap

    Every Liveblocks package should use the same version.

    Terminal
  2. Initialize the liveblocks.config.ts file

    We can use this file later to define types for our application.

    Terminal
  3. Set up the Liveblocks client

    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.

    In Storage mode, documents are created under root._tiptap_docs when the editor first connects, so you can leave initialStorage empty.

    App.tsx
  4. Join a Liveblocks room

    After setting up the room, you can add collaborative components inside it, using ClientSideSuspense to add loading spinners to your app.

    App.tsx
  5. Set up the collaborative Tiptap editor

    Create a Tiptap editor in Editor.tsx. Pass collaborationMode: "liveblocks" to useLiveblocksExtension so the document syncs through Storage. Set a field name and optional initialContent for the first visit.

    Editor.tsx
  6. Render threads

    Comments work the same as in Yjs mode. Create a Threads.tsx file that uses FloatingThreads and AnchoredThreads.

    Threads.tsx
  7. Style your editor

    Import Liveblocks styles, and add basic editor CSS:

    main.tsx
  8. Next: authenticate and add your users

    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

What to read next

Congratulations! You now have set up a Storage-backed collaborative Tiptap editor inside your React application.