Building a Local-First Collaborative Editor With Yjs, Lexical, and IndexedDB

https://hackernoon.imgix.net/images/2jqChkrv03exBUgkLrDzIbfM99q2-pj0221n.jpeg

The question that started Lattiq: why do collaborative editors all feel so brittle? You open Google Docs on the Tube, it spins until you come back above ground, and sometimes it eats your last sentence on the way. The whole assumption is that the server is canonical. Your browser is a dumb terminal that happens to have some cached pixels.

Local-first reverses that assumption. The canonical document lives in your browser. The server, if there is one, is an optimisation: a way to sync with other collaborators when both of you happen to be online. When you go offline, nothing is lost because nothing was ever relying on the connection. When you come back, the CRDT handles the merge without a server arbitrating.

Lattiq is an editor built on that premise. Lexical handles the editing, Yjs handles the CRDT, IndexedDB handles the local persistence, and a thin WebSocket layer handles...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more