Live on Product Hunt Intraface launched today. Less steering, more vacations. See the launch
Start for free

What is a CRDT?

A CRDT (conflict-free replicated data type) is a data structure that several copies can change independently, offline or at the same moment, and that merges those changes by fixed mathematical rules so every copy ends up identical. No server decides the order and nobody resolves a conflict by hand. Counters, sets, maps and text sequences all have CRDT forms.

Part of Glossary: the terms behind MCP, coding agents and shared pages, defined plainly.

How it works

Two replicas take edits on their own, swap states whenever they can, and merge to the same result with no server in between.Alice, offlinereplica Aon Alice's laptopBob, onlinereplica Bon Bob's phonemerge in any order,any number of timessame stateon both, by construction1. edits1. edits2. swap states later3. merge3. merge
  1. Every copy (a replica) accepts changes on its own. No lock, no round trip to a server, and it keeps working offline.

  2. The type is designed so order does not matter: merging two states gives the same result whichever arrives first, and merging twice changes nothing.

  3. Replicas sync by sending whole states (state-based) or the operations they performed (operation-based, usually delivered in causal order).

  4. Once two replicas have received the same set of updates they are in the same state. That guarantee is called strong eventual consistency.

    There is no step where someone picks a winner. The rules picked it in advance.

  5. The cost: the type decides in advance what concurrent changes mean (add wins, last writer wins), and it carries metadata to track who saw what.

Source: crdt.tech: Conflict-free Replicated Data Types

CRDT versus a publish queue with versions

A CRDT merges at the level of single operations: this character inserted here, this element added to that set. Every replica applies every operation, and the data type guarantees they all land in the same place. That is what you want for a text box two people type into at once.

A publish queue is a different trade. Each editor works on a whole copy, then publishes the whole result as a new numbered version. The service lines publishes up and applies them one at a time against the latest version. Intraface works this way: an agent pulls a board, edits its files on your machine, and publishes. Two publishes that touch different files both land; two that touch the same file make the second one pull again and redo its edit. Nothing merges keystrokes, and nothing needs the data type to be convergent, because a human or an agent reviews the whole page before it goes out.

Pick the CRDT when edits are tiny, constant and must feel live. Pick versions when each change is a unit of work you want to see, name and roll back.

Example: two offline edits to one set

Alice and Bob share a tag list, built as an add-wins set. On a plane, Alice adds the tag "urgent". At the same hour Bob, online, removes "urgent" because he thinks it is stale. When Alice lands, the replicas sync. Neither saw the other's change, so the operations are concurrent, and add-wins semantics says the tag stays. Both copies now contain "urgent", and syncing again changes nothing.

The surprise for newcomers is that the outcome was decided when the type was chosen, not when the conflict happened. Had the team picked remove-wins, the tag would be gone on both copies. Both are correct; one of them is what the users expected.

When to use a CRDT

Use one when replicas must accept writes while disconnected, or when there is no server you trust to order everything: peer-to-peer apps, local-first software, multiplayer canvases, and mobile apps that sync later. The 2018 survey by Preguiça, Baquero and Shapiro lists CRDT designs for counters, registers, sets, maps, lists and whole JSON documents, each with its own concurrency semantics.

Skip one when every write already goes through a single server that can order them, or when the merge rule needs human judgement. A version history with a review step is simpler to build and simpler to explain.

Common mistakes

  • Assuming "conflict-free" means "no surprises". It means the replicas never disagree. It does not mean the merged result is what either person meant.
  • Ignoring the metadata. Causality tracking grows with the number of replicas. For a few devices it is noise; for hundreds it limits scale, and compacting it is still open research.
  • Expecting global invariants. A CRDT cannot on its own keep a stock count from going negative or a username unique. Those need coordination, or a design that reserves rights in advance.
  • Confusing it with git. Git merges whole files with a three-way algorithm and stops on conflict. A CRDT never stops; it has an answer for every pair of concurrent operations.

FAQ

Does a CRDT need a central server?
No. Replicas only need some path to exchange states or operations, directly or through relays, and every one of them converges. That is the main difference from Google Docs style editing, where a server orders every change. Many products still run a CRDT behind a server for storage and access control.
Is a CRDT the same as operational transformation?
Both let people edit at once and both end with identical copies. OT transforms each incoming edit against the edits it crossed and usually relies on a server to order them. A CRDT builds the convergence into the data type, so no transformation step and no central ordering is needed.
What is the catch with a CRDT?
The type must settle in advance what concurrent changes mean, and that answer may not be what a person would choose. Tracking causality also costs metadata that grows with the number of replicas, which the 2018 survey by Preguiça, Baquero and Shapiro lists as the open scalability problem.

Stop sending HTMLover Slack.

Create an account in a minute, connect your coding agent, and make your first board.