If you've used Google Docs, Figma, or Notion, you've benefited from real-time collaboration. But how do multiple users edit the same document without conflicts?
Traditional databases use locks or last-write-wins semantics. Neither works well for real-time collaboration — locks create latency, and last-write-wins loses data.
Conflict-free Replicated Data Types are data structures that can be modified independently on different replicas and merged automatically without conflicts.
The key insight is mathematical: if your merge operation is commutative, associative, and idempotent, order doesn't matter. Every replica converges to the same state.
Libraries like Yjs and Automerge make CRDTs accessible. Yjs is particularly impressive — it handles rich text, arrays, and maps with sub-millisecond merge times.
CRDTs aren't free. They use more memory than centralized approaches, tombstones accumulate, and some operations (like "move" in a tree) are notoriously hard to get right.
But for many use cases, the ability to work offline and merge seamlessly is worth the cost.