{
  "id": 21200656,
  "title": "Building a Local-First Collaborative Editor With Yjs, Lexical, and IndexedDB",
  "url": "https://urgent.news/2026/11/22/building-a-local-first-collaborative-editor-with-yjs-lexical-and",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-22T05:00:02.000Z",
  "source": {
    "name": "HackerNoon",
    "slug": "hackernoon",
    "url": "https://hackernoon.com/building-a-local-first-collaborative-editor-with-yjs-lexical-and-indexeddb?source=rss"
  },
  "original_language": "en",
  "account": "This article explains how the Lattiq collaborative editor is built using Yjs, Lexical, and IndexedDB. The key ideas are:\n\n1. Collaborative editors often feel brittle because they assume the server is canonical, but Lattiq reverses that assumption by making the client-side document the canonical source.\n\n2. Yjs provides the CRDT (Conflict-free Replicated Data Type) that enables seamless merging of changes from multiple users, even when offline. It uses a position-based data structure so simultaneous edits don't overwrite each other.\n\n3. The editor initialisation sequence is critical: create the Y.Doc, load from IndexedDB, wait for IndexedDB to finish, then render the editor and connect the WebSocket. Rendering too early causes flickering and lost data. Connecting too early leads to a race condition.\n\n4. Lattiq uses a LocalProvider when offline and a WebSocket provider when online. Both providers share the same Y.Doc, so switching between them doesn't fork the document. The provider abstracts the WebSocket connection away from the editor.\n\n5. The editor exposes a sync status state machine to users, indicating whether changes are local-only, syncing, or synced. This gives users visibility into the collaboration state.\n\nIn summary, Lattiq leverages Yjs for CRDT-based offline editing, Lexical for the rich text editing component, and IndexedDB for local persistence. A carefully crafted init sequence and provider abstraction enable seamless sync between online and offline modes, delivering a fluid collaborative editing experience.",
  "summary": "Most collaborative editors break the moment the connection drops. Lattiq does not, because the source of truth is the user's own browser. This is how to wire...",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}