SQLSync is a collaborative offline-first wrapper around SQLite designed to synchronize web application state between users, devices, and the edge. It allows for eventually consistent data synchronization, enabling real-time local-first collaboration and presence.
The best way to get a feel for how SQLSync behaves is to play with the Todo list demo. Clicking the link will create a unique to-do list and redirect you to its unique URL. You can then share that URL with friends or open it on multiple devices (or browsers) to see the power of offline-first collaborative SQLite.
You can also learn more about SQLSync and its goals by watching Carl's WasmCon 2023 talk. Watch the recording here.
To get started with SQLSync, refer to the guide to learn how to add SQLSync to your application.
By default, SQLSync runs in a shared web worker, allowing the database to be shared between different tabs. This can make SQLSync a bit harder to debug. The easiest way to debug is to use Google Chrome and go to chrome://inspect/#workers
. On that page, you'll find a list of all the running shared workers in other tabs. Assuming another tab is running SQLSync, you'll see the shared worker listed. Click inspect
to open up dev-tools for the worker.
SQLSync uses [rusqlite] under the hood to run and query SQLite. Unfortunately, the execute
method only supports single statements and silently ignores trailing statements. If you are using execute!(...)
in your reducer, make sure that each call only runs a single SQL statement.
For example: