Device sync #2880
Replies: 3 comments 5 replies
-
Hello Luke, Last year we discovered ElectricSQL, which offers exactly what you are asking, a way to sync Postgres with SQLite through a type safe interface, all without limiting SQLite features on the client. The problem was that, at the time it was only compatible with Web technologies. The client is built on top of the drift typed interface and it integrates with drift Stream queries for real time sync updates. Electric is still in open alpha, but the community is very active on Discord. As of today the unofficial Dart client is up to date with all the capabilities the official JS client offers, and we are actively maintaining it. We are still integrating it with our app, but it really feels like magic, we didn't need to change at all our drift code to get the sync capabilities and conflict resolution working. If you give it a try feel free to ask any questions 😄 Just to be clear, this is not a sponsored post. We are really enjoying this technology, and how it is shaping up. And being both Open Source and openly Self Host-able it is just the cherry on top 🙂 |
Beta Was this translation helpful? Give feedback.
-
I've tried Drift with Electric, have also talked with David on the dart electric repo. There is another solution powersync which is similar in working to electric but is fundamentally a middleware between your SQLite and your Postgres db. While electric basically takes over complete control of your Postgres db, powersync is just a middleware. I think instead of me explaining it, this link can explain it much better. What I like is about electric is that it is open source & powersync is not (yet) but they are planning on moving to the open core model (which is open source + an optional hosted version provided by them with some extra features). Performance wise both of them worked equally well for me although I did not test any of them with a lot of rows. Overall, I found powersync to be a better option since it can be removed anytime as it's only a middleware. I can do anything I want in my supabase db and it simply reflects in the app. While in the app I just write to my local Sqlite db and it reflects automatically in the supabase db. Powersync also has official support & SDK for flutter while electric has an unofficial dart client. But @davidmartos96 has done a great job of maintaining it. One thing I like is that dart electric works with drift which is great, powersync use another sqlite package in their SDK. And electric is open source. |
Beta Was this translation helpful? Give feedback.
-
Thanks for starting this discussion, this seems to be a very popular request. My stance is that drift should work well with synchronization services, but not provide its own. Perhaps a first step is to highlight Electric (and also powersync once there's a better way to use that with drift) on drift's documentation website, so that they're easier to find for drift users interested in syncing their database with a postgres server. |
Beta Was this translation helpful? Give feedback.
-
Hi there. Starting to think that flutter is missing a solid local SQLite option that also supports syncing with Postgres or SQLite server.
Drift feels like the ideal package to handle the client side.
Do you have any ideas on the shortest path to adding remote sync (foreground and background) to an app using drift?
The overall goal would be to prototype an app using drift but then have a linear migration path to robust device syncing.
What could be very interesting is using drift on clients and drift with SQLite in WAL mode on the server to enable a low headroom (but perfectly acceptable for most) app architecture hosted on something like fly.io
Beta Was this translation helpful? Give feedback.
All reactions