This particular usage uses the Turso Cloud to sync the local Turso databases and assumes that you have an account.
1
1. Setup Turso Cloud database
- Follow our Quickstart to install the CLI, create a database
-
Get the database URL (
libsql://...):
- Create a token for your app:
2
2. Setup a basic connection with sync
You need three essentials to enable sync:
- Local path: where the local, synced tursodb file is stored
- Remote URL: your Turso Cloud URL (
libsql://...) - Auth token: Turso Cloud token to authenticate requests
On the first run, the local database is automatically bootstrapped from the remote — so the remote must be reachable during the initial connect.If you set
bootstrap_if_empty to false, the local database will start empty instead.
You can bootstrap or update it later at any time by explicitly calling pull().3
3. Push changes
Push sends your local changes to the Turso Cloud server. Under the hood, logical statements are sent, and on conflicts the strategy is “last push wins”.
4
4. Pull changes
Pull fetches remote changes and applies them locally. It returns a boolean indicating whether anything changed.
- Configure
long_poll_timeout_ms/LongPollTimeoutMsif you want the server to wait for changes and avoid empty replies. - If you pushed earlier, a subsequent pull can still return that something changed due to server-side conflict resolution frames.
5
5. Checkpoint
Checkpoint compacts the local WAL to bound local disk usage while preserving sync state.
6
6. Stats
Stats help you observe sync behavior and usage (WAL sizes, last push/pull times, network usage, revision, etc.).