Hi HN!<p>With CRDTs (Conflict-free Replicated Data Types) becoming more mature and getting more attention lately, I decided to dive in and use it as the basis for a new project. I love the technology, and how it enables me to create Google Docs style collaborative apps, that seamlessly sync data across users / devices but also work offline.<p>However, I also found that it's not yet trivial to build! This is why I started building a library that makes developing multiplayer apps super-simple, with a very minimum API surface. (basically, you can just modify plain javascript objects and changes are shared across users).<p>I'm now excited to share SyncedStore - and looking forward to your feedback :)<p>It's designed specifically for React, Vue, Svelte but also works with plain JS. By using Javascript Proxies, the data store looks like plain javascript objects, except that they'll now sync automatically across devices / users!
Would you care to compare this with for example @localfirst/state, automerge and automerge-rs (latter two provide the CRDTs, i.e. similar to Yjs)?<p><a href="https://github.com/local-first-web/state" rel="nofollow">https://github.com/local-first-web/state</a><p><a href="https://github.com/automerge/automerge" rel="nofollow">https://github.com/automerge/automerge</a><p><a href="https://github.com/automerge/automerge-rs" rel="nofollow">https://github.com/automerge/automerge-rs</a><p>By the way despite that particular repo (@localfirst/state) last being touched 6 months ago, Herb Caudill definitely seems still active in this space (I believe he's been working on other parts of this more recently -- e.g. ideas about authentication), and I think automerge development itself (Martin Kleppmann) is quite active right now leading up to a 1.0 release which seems fairly imminent, for which a lot of fundamental work has been done, also coordinating with automerge-rs.
Wow this is so awesome!<p>How/where does the data get saved for later? I'm guessing from the example, you don't need a database? E.g. I can just save the data to a document database, and next time someone works on it, just sync with the database? Or do I not need it at all because it's stored on the browser? And how would the information be associated with accounts, if someone wanted that feature?<p>Also curious how/where the demo site is deployed (guessing Vercel doesn't work since they don't seem to support websockets? I see that Hocuspocus is mentioned — is that required as a backend to make it all work?<p>Sorry I'm new to all of this and it sounds like magic, but I'd LOVE to learn how to implement this; especially on something like Vercel, if possible
Pretty interesting project. I'm curious what the data structure looks like that is sent over the network for diffs. I found the part about state-vector, but not about the actual data.<p>Does it diff the JSON string, or the objects/array themselves? Does it serialize the data or leave as plain text?<p>I ask, because I have a similar setup, that needs to sync dynamic data structures, but also keep the data deltas as small as possible when sharing them as JSON strings to save bandwidth.
How does the y-websocket handles network failure ?<p>Does it autoreconnet? On reconnection, does it sync back changes that happened on or since failure ? Can you notify the user when it's happening ?
Love this! Thanks for sharing, I have some amazing use cases for this type of work and I can't wait to dig into the code to learn more. The future for CRDT is indeed hot right now and everyone wants it into their app, Google paved the way and now other big names, like Figma, Invision etc are getting on this hard!
FYI, the examples don't work for me in Brave browser on linux:<p>React example: "/App.tsx: Cannot read property 'getItem' of null (2:0)"<p>Vue example: "file:///src/store.ts: Cannot read property 'getItem' of null (1:0)"<p>Works fine in Chromium and Firefox though, so not sure what's up.
This is awesome to see. I have gotten interested in CRDTs in the last couple years due to them being used in the Elixir/Phoenix ecosystem.<p>One question though, how do you integrate a backend into your library? I don't see anything mentioned in the docs.