OT and CRDT trade-offs for Real-Time collaboration
Wanderlog (<a href="https://wanderlog.com" rel="nofollow">https://wanderlog.com</a>) is a Google Docs for planning travel, and naturally, we had to figure this out early in the process.<p>If you're on a Node.js/React stack, we highly recommend using the combination of OT-JSON0 [1] and ShareDB [2], two excellent libraries. OT-JSON0 lets you perform operational transforms on any JSON-serializable structure pretty intuitively, and ShareDB handles synchronizing it between multiple clients and resolving conflicts. Building your own is going to be a pain, so unless your core business is a text editor like TinyMCE, it's probably best to stand on the shoulders of giants.<p>Another approach that we didn't end up using is Figma's: especially if you're working on anything other than text editing, ask if you actually want to use operational transform. Something simpler might be good enough -- in Figma's case, they use "last write wins" because they were able to break the document into small enough, atomic elements. [3]<p>[1] <a href="https://www.npmjs.com/package/ot-json0" rel="nofollow">https://www.npmjs.com/package/ot-json0</a><p>[2] <a href="https://www.npmjs.com/package/sharedb" rel="nofollow">https://www.npmjs.com/package/sharedb</a><p>[3] <a href="https://www.figma.com/blog/how-figmas-multiplayer-technology-works/stack" rel="nofollow">https://www.figma.com/blog/how-figmas-multiplayer-technology...</a>