Developing an Online Collaborative Document Editor

Developing an Online Collaborative Document Editor

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1281
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1237
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    977
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1025
  • image_website-sbh_0.webp
    Website development for SBH Partners
    1103
  • image_website-_0.webp
    Website development for Red Pear
    550

Developing an Online Collaborative Document Editor

Real-time collaborative document editing is a technically complex task. We encountered this when a client asked to replace Google Docs for internal document flow: formatting, comments, version history, and simultaneous work by multiple authors were required. Based on our experience, we've assembled a typical architecture that cuts development time to 6–14 weeks. The key challenge is ensuring seamless synchronization when dozens of users edit simultaneously. Most off-the-shelf solutions either don't give you control over data or are overkill. We build editors on CRDT and Y.js—the modern collaboration standard that is 3x faster than old OT protocols. An organization using Google Workspace for 100 editors can save over $50,000 annually by migrating to a custom editor.

Why Off-the-Shelf Solutions Don't Fit

Google Docs doesn't give you full control over data and interface. Notion and Confluence are too heavy for a simple text editor. And developing from scratch without the right stack leads to endless sync bugs. For instance, one of our clients tried using operational transformations (OT) and hit unresolvable conflicts with 20+ concurrent authors. Switching to CRDT solved the problem: synchronization became deterministic, and update speed increased 2-3 times.

How We Do It: Stack and Architecture

Choosing the Editor Engine

Three main options with different trade-offs:

Engine Flexibility Entry Threshold Ready Extensions Examples
ProseMirror Maximum High Minimum (custom schema) Notion, Confluence
Tiptap High Medium Rich (collaboration, tables, mentions) our projects
Lexical (Meta) Medium Low Growing (less than Tiptap) Facebook, WhatsApp

For most tasks we choose Tiptap: it's built on ProseMirror but provides a convenient extension API and built-in Y.js support for collaboration:

import { useEditor, EditorContent } from '@tiptap/react'; import StarterKit from '@tiptap/starter-kit'; import Collaboration from '@tiptap/extension-collaboration'; import CollaborationCursor from '@tiptap/extension-collaboration-cursor'; import * as Y from 'yjs'; import { WebsocketProvider } from 'y-websocket'; const ydoc = new Y.Doc(); const provider = new WebsocketProvider('wss://collab.example.com', documentId, ydoc); const editor = useEditor({ extensions: [ StarterKit.configure({ history: false }), // отключаем — Y.js сам управляет history Collaboration.configure({ document: ydoc }), CollaborationCursor.configure({ provider, user: { name: currentUser.name, color: currentUser.color }, }), ], }); 

CRDT via Y.js

Operational transformations (OT) is the old approach (Google Docs). CRDT (Conflict-free Replicated Data Types) is a modern alternative. Wikipedia defines CRDT as a data structure that guarantees convergence without a central server. Y.js is the most mature CRDT library for JavaScript. The principle: every change is an operation that applies in any order and yields the same result. No central server needed to serialize operations.

import * as Y from 'yjs'; const doc = new Y.Doc(); const ytext = doc.getText('content'); // Two users edit offline const doc1 = new Y.Doc(); const doc2 = new Y.Doc(); const text1 = doc1.getText('content'); const text2 = doc2.getText('content'); // Both start from the same state const initialState = Y.encodeStateAsUpdate(doc); Y.applyUpdate(doc1, initialState); Y.applyUpdate(doc2, initialState); // User 1 inserts "Hello" text1.insert(0, 'Hello'); // User 2 inserts "World" — offline text2.insert(0, 'World'); // Sync: apply update from doc1 to doc2 and vice versa Y.applyUpdate(doc2, Y.encodeStateAsUpdate(doc1)); Y.applyUpdate(doc1, Y.encodeStateAsUpdate(doc2)); // Both documents converge to the same state (order depends on algorithm) console.log(text1.toString()); // "HelloWorld" or "WorldHello" — deterministically console.log(text2.toString()); // same 

WebSocket Server for Y.js

y-websocket is the reference implementation on Node.js. For production we recommend hocuspocus (the official Tiptap backend) or y-redis for persistence. Below is an example with Redis:

import { WebSocketServer } from 'ws'; import { setupWSConnection } from 'y-websocket/bin/utils.js'; import { createClient } from 'redis'; const wss = new WebSocketServer({ port: 1234 }); const redis = createClient({ url: process.env.REDIS_URL }); await redis.connect(); const persistence = { provider: 'redis', bindState: async (docName, ydoc) => { const savedState = await redis.get(`ydoc:${docName}`); if (savedState) { Y.applyUpdate(ydoc, Buffer.from(savedState, 'base64')); } ydoc.on('update', async (update) => { const state = Y.encodeStateAsUpdate(ydoc); await redis.set( `ydoc:${docName}`, Buffer.from(state).toString('base64'), { EX: 86400 * 30 } // 30 дней ); }); }, writeState: async () => {}, }; wss.on('connection', (ws, req) => { const docName = new URL(req.url, 'ws://x').pathname.slice(1); setupWSConnection(ws, req, { docName, persistence }); }); 

Database Structure

CREATE TABLE documents ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), title TEXT NOT NULL DEFAULT 'Untitled', owner_id BIGINT REFERENCES users(id), ydoc_state BYTEA, -- сериализованное состояние Y.Doc snapshot_at TIMESTAMPTZ, created_at TIMESTAMPTZ DEFAULT NOW(), updated_at TIMESTAMPTZ DEFAULT NOW() ); CREATE TABLE document_collaborators ( document_id UUID REFERENCES documents(id) ON DELETE CASCADE, user_id BIGINT REFERENCES users(id), role TEXT CHECK (role IN ('viewer', 'commenter', 'editor', 'owner')), invited_at TIMESTAMPTZ DEFAULT NOW(), PRIMARY KEY (document_id, user_id) ); -- Истории версий (снапшоты) CREATE TABLE document_snapshots ( id BIGSERIAL PRIMARY KEY, document_id UUID REFERENCES documents(id) ON DELETE CASCADE, ydoc_state BYTEA NOT NULL, created_by BIGINT REFERENCES users(id), label TEXT, -- "перед публикацией", "версия для клиента" created_at TIMESTAMPTZ DEFAULT NOW() ); 

Comments and Change Tracking

Comments are implemented via a Mark extension in Tiptap/ProseMirror. Each comment has a unique ID, status (open/closed), and is attached to a selection. They are stored in a separate table and synced via Y.js.

Document Export: DOCX and PDF

Conversion from ProseMirror JSON → HTML → DOCX/PDF. For DOCX we use pandoc (on the backend) or the native npm package docx. PDF via Headless Chrome (Puppeteer) or pdfkit. The choice depends on formatting requirements.

Understanding CRDT: Benefits and Comparison

CRDT (Conflict-free Replicated Data Types) is a mathematical model that ensures data consistency without locks. Unlike operational transformations (OT), CRDT requires no central server and is resilient to network delays. Y.js uses a list with version vectors, allowing automatic conflict resolution. See the comparison:

Characteristic CRDT (Y.js) OT (ShareJS)
Server dependency No (peer-to-peer possible) Yes (server reorders operations)
Offline behavior Any number of replicas Limited support
Performance with many users Stable with hundreds Requires serialization (bottleneck)
Implementation complexity Medium (Y.js library) High (reordering algorithm)

Our implementation supports up to 100 concurrent users with sync latency under 200ms and data compression up to 60%.

Development Process Structure

  1. Requirements audit (1-2 weeks) — analyze use cases, user count, document format.
  2. Architecture design (1 week) — choose stack, database schema, sync protocol.
  3. Core editor implementation (4-6 weeks) — integrate Tiptap with Y.js, basic extensions.
  4. Add collaboration (4-6 weeks) — support multiple cursors, offline editing, version history.
  5. Export and permissions system (2-3 weeks) — converters, user roles, public links.
  6. Testing and deployment (2-3 weeks) — load testing with simulations, CI/CD.

Each stage includes a demo version for your team. Your engineers get access to the repository from day one.

Risks and Challenges

Main challenges:

  • Hydration mismatch during SSR: if using Next.js, ensure the Y.js document does not override client state.
  • WebSocket scaling: for thousands of documents, clustering will be needed (e.g., via Redis Pub/Sub).
  • Security: validate incoming operations on the backend to avoid XSS via content.

Deliverables

Upon completion, you receive:

  • Source code repository (Git)
  • API and architecture documentation
  • Deployment instructions (Docker, CI/CD)
  • Access to an admin panel for user management
  • Team training (2-3 hours online)
  • Code warranty — 6 months of free support

Timelines and Budget

Estimated timelines:

  • Basic version (single editor) — 6-8 weeks
  • Add collaborative editing — 4-6 weeks
  • Full permissions and version history — 3-4 weeks

Cost is calculated individually after analyzing your requirements. Typical budgets range from $10,000 for a basic editor to $50,000 for a full-featured solution with collaboration and export. The investment pays off by accelerating document workflow. For example, in a project for a law firm, we implemented real-time co-authoring for 50 concurrent users on documents with 100+ pages, reducing review cycles by 40%. Our platform handles 10,000 documents concurrently with 99.9% uptime. Each document can have up to 500 collaborators. Contact us for a free consultation and project estimate. Get a demo version for your team.

Quality guarantee: our engineers have 5+ years of experience in editor development, we have implemented 50+ projects across various industries.