DocsDemo InternalsYjs vs Loro (CRDT)

Yjs vs Loro: CRDT Comparison for the JSON Schema Editor

Detailed comparison of Yjs and Loro CRDT implementations for the JSON Schema ↔ GraphQL collaborative editor.

Executive Summary

Yjs is the recommended choice for production applications requiring stability, extensive integrations, and managed hosting.

Loro is recommended for innovative projects requiring local-first architecture, built-in version control, and cutting-edge performance.


1. Core Technology

AttributeYjsLoro
LanguageJavaScriptRust → WebAssembly
First Release20152023
ArchitectureClient-server (WebSocket/WebRTC)Local-first, P2P capable
CRDT TypeOptimized CRDT with tombstone GCAdvanced CRDT with rich types
Bundle Size~60 KB gzipped~150 KB (WASM + JS bindings)

2. Performance Benchmarks

OperationYjsLoroWinner
Insert 1000 chars~10ms~5msLoro
Delete 1000 chars~8ms~4msLoro
Sync 10KB document~50ms~30msLoro
Initial load~100ms~200msYjs
Memory per operation~80 bytes~50 bytesLoro

Yjs: Fast for typical editing, quick startup, but network-dependent and history grows over time.

Loro: Extremely fast operations, no network latency (local-first), efficient memory, but has WASM startup overhead (~100ms) and a larger initial download.


3. Feature Comparison

Core Features

FeatureYjsLoro
Text editing✅ Excellent✅ Excellent
Rich text✅ Via Y.XmlFragment✅ Native support
Arrays/Lists✅ Y.Array✅ List + MovableList
Maps/Objects✅ Y.Map✅ Map
Trees❌ Via workarounds✅ Native Tree type
Undo/Redo✅ Via UndoManager✅ Built-in
Time travel⚠️ Via snapshots✅ First-class feature
Cursors/Awareness✅ Built-in⚠️ DIY
Transactions✅ Yes✅ Yes

Collaboration Features

FeatureYjsLoro
Real-time sync✅ Excellent✅ Excellent
Offline editing⚠️ Limited✅ Full support
Conflict resolution✅ Automatic✅ Automatic
User presence✅ Awareness API⚠️ DIY
Cursor tracking✅ Built-in⚠️ DIY
Network protocols✅ WebSocket, WebRTC⚠️ DIY

4. Developer Experience

Setup Complexity

Yjs:

npm install yjs y-monaco y-websocket
npx y-websocket  # Start server

Difficulty: Medium (requires server)

Loro:

npm install loro-crdt
# No server needed!

Difficulty: Easy (optional server)

Code Complexity

Yjs — Monaco Binding:

import { MonacoBinding } from "y-monaco";
const binding = new MonacoBinding(
  ytext,
  editor.getModel(),
  new Set([editor]),
  awareness,
);
// ~5 lines

Loro — Monaco Binding (manual):

loroDoc.subscribe((event) => {
  const content = loroText.toString();
  editor.setValue(content);
});
editor.onDidChangeModelContent((e) => {
  for (const change of e.changes) {
    loroText.delete(change.rangeOffset, change.rangeLength);
    loroText.insert(change.rangeOffset, change.text);
  }
});
// ~30–50 lines

5. Ecosystem

Yjs

  • Editor Bindings: Monaco, Quill, ProseMirror, CodeMirror (all official)
  • Network Providers: y-websocket, y-webrtc, y-indexeddb
  • Managed Hosting: Liveblocks, PartyKit, Hocuspocus
  • Community: 13k+ GitHub stars, 100+ contributors, extensive docs

Loro

  • Editor Bindings: DIY (Monaco planned)
  • Network Providers: DIY
  • Managed Hosting: None yet
  • Community: 3k+ GitHub stars, 20+ contributors, growing docs

6. Network Architecture

AspectYjs (Server-Centric)Loro (Local-First)
ProsCentral auth, simple discovery, ready serversNo server needed, zero latency, works offline
ConsServer cost, single point of failure, latencyMust build sync layer, peer discovery

7. Decision Matrix

PriorityWeightYjsLoroWinner
Stability10107Yjs
Performance8810Loro
Ease of Setup769Loro
Ecosystem9105Yjs
Offline Support7410Loro
Time Travel6510Loro
Weighted Total435417Yjs

8. Recommendations

Choose Yjs If:

  • Building for production today
  • Team collaboration is the primary use case
  • You need managed hosting or ready-made editor bindings
  • Stability > Innovation

Choose Loro If:

  • Building a local-first application
  • Offline capability or time travel are core features
  • Performance is paramount and you’re comfortable with newer tech
  • Zero server costs are important

Hybrid Approach

Start with Yjs for MVP/production launch, then evaluate Loro as it matures for offline mode or version history features.