When multiple devices edit the same file while offline, conflicts are inevitable. Below are proven patterns to resolve these conflicts gracefully:
- Last Writer Wins (LWW) – The most recent change overwrites previous ones. Simple but may cause data loss.
- Operational Transform (OT) – Transform concurrent edits into a single consistent state. Used by Google Docs.
- Conflict‑Free Replicated Data Types (CRDTs) – Merge changes automatically without central coordination.
- Versioned Branching – Create a new version for each edit and let users merge manually.
- User‑Prompted Merge – Detect conflict and present a UI for the user to choose the resolution.
Each pattern has trade‑offs in terms of complexity, bandwidth, and user experience. Choose the one that aligns with your product's priorities.
I’ve implemented OT in a collaborative markdown editor and it works well for real‑time sync, but the algorithm is non‑trivial.