What is CRDT (Conflict-free Replicated Data Type) and how does it apply to real-time collaboration?

Answer

CRDTs are data structures designed to be replicated across multiple nodes where updates can be made concurrently without coordination, and all replicas eventually converge to the same state — without requiring a central authority to resolve conflicts. Types: G-Counter (grow-only counter), LWW-Register (last-write-wins), RGA/LSEQ (ordered lists for collaborative text editing). In real-time collaborative applications (Google Docs, Figma, Notion), CRDTs enable offline editing — users can edit without a server connection, and changes merge deterministically when they reconnect. The Yjs library implements CRDT-based shared data types (Y.Text, Y.Map, Y.Array) and integrates with WebSocket providers (y-websocket) to sync state across clients. Unlike Operational Transformation (OT, used by Google Docs's older system), CRDTs don't require a central server to transform operations — all replicas can merge directly. Automerge is another popular CRDT library.