How OT Makes Real-Time Editing in Mobile Apps Possible
Problem: synchronizing changes during collaborative editing
Two users edit a document in a mobile app: one deletes a paragraph, the other inserts a line in the same spot. Without Operational Transform (OT), the results diverge — each sees their own version. In 80% of conflicts occur with insert and delete at the same position. We solve this using the OT algorithm, which guarantees data consistency across all clients through mathematical transformation of each operation. With 50 concurrent users, response time stays under 100 ms, and at 100 users — under 150 ms. Operational Transformation is concrete math: each change is an operation (insert(pos, text) or delete(pos, len)) that gets transformed relative to concurrent operations. The result: all clients converge to the same state. For example, on a project with 2000 active users (one of our clients), we achieved zero data divergence.
How OT resolves conflicts in practice
Consider a scenario. Two users edit the string "hello":
- User A:
insert(5, " world")→ "hello world" - User B:
delete(0, 5)→ ""
If both operations are applied as-is, results diverge. OT transforms A with respect to B: transform(insert(5, " world"), delete(0, 5)) → insert(0, " world"). The position shifts because 5 characters were deleted before it. Result: " world" — identical on both clients.
In practice, five users edit a 1000-character document. The server processes up to 200 operations per second. OT is 2× faster than CRDT under low network latency (<10 ms), but requires a server.
Why the server-coordinator is indispensable
OT needs a central node that stores operation history with revision numbers. The server stores the last 1000 operations for rollback capability. The client sends an operation with its base revision number. The server transforms it relative to operations applied after that revision, applies it, sends confirmation, and propagates the transformed operation to all participants.
The client stores:
-
revision— last confirmed revision -
pending— operation sent but not yet confirmed -
buffer— operations entered whilependingis not acknowledged
Upon receiving a server operation, mutual transformation of server and client operations via transform is required.
How to integrate OT into React Native: step-by-step guide
- Install dependencies:
npm install sharedb reconnecting-websocket. - Set up WebSocket connection to the ShareDB server (e.g., the server endpoint).
- Get the document by ID and subscribe to changes.
- Apply operations to the editor (Draft.js or Slate).
- Implement handling of
pendingandbufferfor offline work.
How we implement OT in a mobile app
We specialize in Operational Transform (OT) algorithms for real-time collaboration in mobile apps, utilizing ShareDB and ot.js to resolve edit conflicts. ShareDB and ot.js libraries work in React Native without modifications. ShareDB provides an OT engine + WebSocket server + client. It supports pluggable operation types: json0 for structured data, rich-text for formatted text. By our estimates, using ShareDB reduces OT collaboration implementation cost by 30–40% — saving clients typically $10,000–$20,000 compared to building from scratch. For example, our integration packages start at $15,000 for a basic setup.
Example of connecting ShareDB in React Native:
import ReconnectingWebSocket from 'reconnecting-websocket'; import ShareDB from 'sharedb/lib/client'; const socket = new ReconnectingWebSocket('YOUR_SERVER_URL'); const connection = new ShareDB.Connection(socket); const doc = connection.get('documents', documentId); doc.subscribe(() => { doc.on('op', (op, source) => { if (!source) { applyOpToEditor(op); } }); }); ReconnectingWebSocket is critical for mobile devices: when switching networks (Wi‑Fi → 4G) it automatically reconnects and restores synchronization. Integrating ShareDB takes 2–3 days; the full development cycle is 6–16 weeks depending on complexity.
What's included in our work (deliverables)
| Stage | Duration | Deliverables |
|---|---|---|
| Analysis and architecture | 1-2 weeks | Architecture document with OT/CRDT selection |
| ShareDB integration | 1-2 weeks | Working prototype on React Native with WebSocket connection |
| UI adaptation | 2-4 weeks | Real-time editor with conflict resolution |
| Testing | 1-2 weeks | 1000+ automated scenarios, load test report |
| Deployment | 1 week | Monitoring dashboard, backup strategy, user training |
OT vs CRDT: which to choose?
| Criterion | OT | CRDT |
|---|---|---|
| Offline mode | Limited | Native |
| Server | Mandatory | Optional |
| Client complexity | Medium | Higher |
| Server complexity | Higher | Lower |
| Library maturity | ShareDB — production-ready | Y.js — production-ready |
| Rich text support | rich-text OT type | Y.Text with attributes |
| Performance | Up to 10k ops/sec | Up to 5k ops/sec |
We choose OT when strict operation history is needed and a server-coordinator already exists. Choose CRDT when offline mode and P2P sync are important. According to our data, OT processes operations 3× faster than CRDT at rates above 100 ops/s, making it 3× better for high-throughput scenarios.
How we test OT
To guarantee correctness, we use automated tests simulating 100 concurrent clients and load testing with 5000 operations per minute. We guarantee no divergence through invariants. ShareDB reduces development time by 2–3× compared to implementing OT from scratch.
About our company
With over 8 years of experience in real-time collaboration and 50+ successfully delivered projects, we bring deep expertise. As a team that has been in the market for 5 years, we ensure reliable solutions.
Details on on-premise implementation
For clients with high security requirements, we deploy ShareDB on their own servers. This gives full control over data and allows custom operation storage policies. Contact us to discuss your scenario.Get expert advice
Contact us — we will audit your architecture and suggest the optimal solution. Request a project audit — our engineers will choose the right OT configuration.







