Skip to content

What are CRDTs

Key idea:

CRDT (Conflict-free Replicated Data Types) — a class of data structures that can be updated independently on multiple replicas and merged deterministically without conflict resolution. Foundation of collaborative editors (Notion, Figma, Linear). Types: G-Counter (grow-only), LWW-Set (last-write-wins), RGA (replicated growable array for text). Libraries: Yjs, Automerge.

Below: details, example, related terms, FAQ.

Details

  • Commutative: A+B = B+A (operation order irrelevant)
  • Associative: (A+B)+C = A+(B+C)
  • Idempotent: applying the same update twice = same result
  • Vector clocks / Lamport timestamps for ordering
  • Use cases: collaborative editing, offline-first, distributed counters

Example

// Yjs collaborative text
const ydoc = new Y.Doc();
const ytext = ydoc.getText('content');
ytext.insert(0, 'Hello');
// Syncs over WebSocket — other users see update

Related Terms

Learn more

Frequently Asked Questions

CRDT vs Operational Transform?

OT (Google Docs) — server-authoritative, transforms operations. CRDT — peer-to-peer compatible, merges without a server. CRDT wins offline-first.

Performance?

Yjs handles thousands of edits/sec. Automerge is slower but more featureful. Both in production (Linear, Figma).

Do I need it for a simple todo app?

No — overhead. CRDTs make sense for collaborative editing or true offline-first UX.