Offline-First Sync: Conflict Resolution Strategies (CRDTs and Beyond)
By Mykhailo Boichuk · Co-founder & Vice-President
In short
When an offline-first app lets multiple devices edit the same data while disconnected, it must merge those edits when they reconnect. The main strategies are last-writer-wins, which is simple but can silently lose data; operational transformation, which is powerful but complex; and conflict-free replicated data types (CRDTs), which merge automatically and converge but add metadata and design constraints. The right choice depends on the data type and how much loss is acceptable.
The core problem
Offline-first software accepts edits on a device even when it cannot reach the server or other devices. The benefit is that the app always works. The cost is that two devices can change the same piece of data independently, and when they reconnect, the system has to combine those changes into a single consistent state. This is the conflict-resolution problem, and it is the defining engineering challenge of offline-first design.
There is no free solution. Every strategy makes a trade-off between simplicity, correctness, and how often it surprises the user by discarding work. Choosing among them is mostly about understanding the data and the acceptable failure modes.
Last-writer-wins
The simplest strategy keeps whichever edit has the latest timestamp and discards the other. Last-writer-wins is easy to implement and easy to reason about, which is why it is common. Its weakness is equally clear: when two people edit the same field concurrently, one person’s change is silently lost, with no record that it ever existed.
- Simple to build and predictable in behavior.
- Can silently discard a concurrent edit, which users experience as lost work.
- Depends on clock accuracy across devices, which is itself a source of error.
- Acceptable for low-stakes fields where losing one edit is tolerable.
Operational transformation
Operational transformation (OT) takes a different approach: it represents edits as operations and transforms concurrent operations against one another so they can be applied in any order and still converge. It is the technique behind several well-known collaborative editors and can preserve both users’ intentions in many cases.
Conflict-free replicated data types
Conflict-free replicated data types (CRDTs) are data structures designed so that concurrent updates always merge into the same result, regardless of the order in which devices exchange them. The system guarantees convergence by construction, which removes the need for a central authority to decide conflicts and makes CRDTs a natural fit for offline-first and peer-to-peer designs.
The cost is that CRDTs carry extra metadata to track causality, which adds storage and bandwidth, and not every data model maps cleanly onto an existing CRDT type. There is a growing library of CRDTs for common structures such as counters, sets, and ordered lists, and choosing the right one for the data is the main design task.
- 1.Identify the data type and how it can be concurrently edited.
- 2.Choose a strategy: last-writer-wins for low-stakes fields, a CRDT where automatic convergence matters, OT where it is already proven for your case.
- 3.Decide what happens to genuinely conflicting intent, including whether to surface a conflict to the user.
- 4.Test with realistic offline and reconnection scenarios, not just the happy path.
Key takeaways
- Offline-first apps must merge concurrent edits made on disconnected devices.
- Last-writer-wins is simple but can silently lose a concurrent edit.
- Operational transformation can preserve intent but is hard to implement correctly.
- CRDTs guarantee convergence by construction at the cost of extra metadata.
- The right strategy depends on the data type and how much loss is acceptable.
Frequently asked questions
- What is a conflict in offline-first sync?
- It occurs when two or more devices change the same data while disconnected, so when they reconnect the system must merge the divergent edits into one consistent state.
- What is a CRDT?
- A conflict-free replicated data type is a data structure designed so concurrent updates always merge to the same result regardless of order, guaranteeing convergence without a central authority to resolve conflicts.
- Why not just use last-writer-wins everywhere?
- Because it silently discards a concurrent edit, which users experience as lost work. It is acceptable for low-stakes fields but risky where preserving every edit matters.
References
About the author
Mykhailo Boichuk
Co-founder & Vice-President
Mykhailo is an engineer who builds native applications and the systems behind them. He concentrates on macOS and iOS performance, local-first data architecture, and the synchronization problems that come with offline-capable software.