A real-time, collaborative document editing platform inspired by Google Docs. This project leverages modern web technologies to provide seamless real-time collaboration, document management, and rich text editing.
- Framework: Next.js 15 (React 19)
- Styling: Tailwind CSS & Radix UI
- Authentication: Clerk
- Database & Backend: Convex
- Real-time Collaboration: Liveblocks (with Yjs)
- Rich Text Editor: Tiptap
- State Management: Zustand
/(Home): The dashboard where users can view their recent documents, search for documents, and create new ones from blank or templates./documents/[documentId]: The core document editor page where the real-time collaborative editing takes place.
/api/liveblocks-auth: Authenticates users connecting to Liveblocks rooms, ensuring that only authorized users can join and edit a specific document.
@clerk/nextjs: Handles user authentication, registration, and session management.convex: A serverless backend and database providing real-time data syncing for document metadata (titles, owners, organization IDs).@liveblocks/react,@liveblocks/node: Powers multiplayer features including live cursors, presence, real-time syncing of the document content, and commenting/threads.@tiptap/react,@tiptap/starter-kit,@tiptap/extension-collaboration: The headless rich-text editor framework integrated with Liveblocks (via Yjs) for conflict-free collaborative editing.zustand: Lightweight state management for handling global UI states.lucide-react: Beautiful and consistent iconography.
- Clerk: Used for managing user identities. The application uses Clerk to authenticate users before they can access their dashboard or any documents.
- Convex: Used as the primary database to store document metadata. When a document is created, its initial state, title, and ownership details are stored in Convex.
- Liveblocks: Manages the WebSocket connections for real-time collaboration. The actual content of the document being actively edited is synced through Liveblocks rooms.
The UI is built using Tailwind CSS for utility-first styling and Radix UI for accessible, unstyled component primitives. Key components include:
Editor(src/components/Editor.tsx): The core Tiptap editor instance configured with necessary extensions (formatting, tables, tasks, collaboration).HomeNavbar&DocumentNavbar: Navigation bars for the dashboard and document editing views respectively.Toolbar(src/components/toolbar): The rich-text formatting toolbar (bold, italic, alignment, font selection, colors) that interacts with the Tiptap editor.TemplateCarousel(src/components/TemplateCarousel.tsx): A carousel component for selecting document templates on the home page.Threads(src/components/Threads.tsx): Liveblocks-powered inline commenting and threading system within the document.ui(src/components/ui): Reusable, atomic UI components (Buttons, Dialogs, Dropdowns, Inputs) built with Radix UI and Tailwind.
- Authentication: A user accesses the application and is prompted to log in via Clerk.
- Dashboard: Once authenticated, the user lands on the Home (
/) page. The app fetches the user's documents from Convex. - Document Creation: The user can create a new blank document or choose a template from the
TemplateCarousel. This triggers a Convex mutation to create a new document record in the database. - Entering the Editor: The user is routed to
/documents/[documentId]. - Real-time Connection:
- The application calls the
/api/liveblocks-authendpoint to get a secure token. - A Liveblocks
RoomProviderconnects the user to a specific room matching thedocumentId.
- The application calls the
- Collaborative Editing:
- The Tiptap editor initializes with the
@tiptap/extension-collaborationextension. - Any keystrokes, formatting changes, or cursor movements are broadcasted via Liveblocks to all other users in the same room instantly.
- The Tiptap editor initializes with the
- Commenting: Users can highlight text and add comments using the Liveblocks Thread functionality, which is rendered using the
Threadscomponent. - Persistence: While active typing is synced via Liveblocks, the final document state and metadata are periodically synced back to Convex for long-term storage.
You need Node.js installed and accounts/API keys for Clerk, Convex, and Liveblocks.
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables. Create a
.env.localfile based on.env.example:NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=... CLERK_SECRET_KEY=... NEXT_PUBLIC_CONVEX_URL=... NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY=... NEXT_PUBLIC_LIVEBLOCKS_SECRET_KEY=...
- Start the development server:
npm run dev
- Open http://localhost:3000 in your browser.