Collabs Documentation¶
Collabs is a library for collaborative data structures (CRDTs). These are data structures that look like Set
, Map
, Array
, etc., except that they are synchronized between multiple users: when one user changes a collaborative data structure, their changes show up for every other user. You can use them to build collaborative apps along the lines of Google Docs/Sheets/Slides, shared whiteboards, etc.
Install¶
npm i --save @collabs/collabs
Collabs is written in TypeScript and should work in any JavaScript environment (browser, Node.js, etc.).
Consider using our app template.
Demos¶
Live demos of collaborative apps built using Collabs (source code).
fileshare-recipe-editor, a collaborative recipe editor that syncs through Dropbox.
How it Works¶
Collabs implements hybrid op-based/state-based Conflict-free Replicated Data Types (CRDTs). These ensure that collaborators converge to a consistent state once they apply the same updates, regardless of order. We also try hard to converge to a “reasonable” result when users make concurrent changes.
Our built-in CRDTs implement modern algorithms including Peritext, Fugue, and a list with a move operation.
Principles¶
See our talk at LFW.dev meetup #5: Video, Slides, Live demo.
Local-first ready: Collabs lets users work offline and sync up with collaborators later. We use CRDTs to merge changes even with arbitrary latency and concurrency.
Network- and storage-agnostic: Collabs generates updates that you must eventually deliver to all collaborators, but you are free to deliver and store these updates however you like. We also publish providers that handle this for you.
Keep your data model and type safety: A key feature of Collabs is that you can organize your collaborative state using encapsulated, strongly-typed classes.
Flexible and extensible: Collabs is a library for collaborative data structures, not just a menu of built-in options (but we provide those too). So if our data structures don’t meet your needs, you can create your own and even publish them as 3rd-party libraries: new semantics, faster algorithms, CRDT paper implementations…