Menu

1 / 5

crdt-sync: a small local-first sync engine in Rust, with CRDTs, sqlite and websockets

DEV Community: rust·Abdeldjalil Chougui·2 days ago
#WTgCMOXi
#devtorust#devto#dev#server#sync
Long article (1554 words) — no AI summary yet.
Reading 0:00
15s threshold

Two people edit the same note. One is on a train with no signal, the other at a desk. Both keep typing. When the train leaves the tunnel, what should the note look like?

The classic answer is to make the server the judge: every edit goes to it, it decides the order, and a client without a connection waits. Local-first apps turn this around. Each device holds a full copy, edits apply immediately and offline, and devices exchange changes whenever they can reach each other. The hard requirement is that after exchanging everything, all copies are identical, no matter in which order the changes arrived.

Data structures with that guarantee are called CRDTs, conflict-free replicated data types. Automerge and Yjs are the well-known libraries built on them. They are mature, optimized libraries, which makes them a long read if your goal is to learn how the idea works.

crdt-sync is a small local-first sync engine in Rust. Documents are trees of CRDTs, backed by an operation log and vector clocks.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.