Skip to main content
The tursodb CLI includes a built-in sync server that you can run locally. This lets you develop and test sync workflows entirely on your machine — no Turso Cloud account required.
The local sync server implements the same sync protocol as Turso Cloud, so your application code works the same way in both environments.

Starting the server

Pass --sync-server with an address to start the sync server. The database argument specifies where the server stores its data:
tursodb ./server.db --sync-server 0.0.0.0:8080
This starts a sync server listening on port 8080, backed by ./server.db.

Connecting clients

Point your sync client at http://localhost:8080. No auth token is needed for the local server.
import { connect } from '@tursodatabase/sync';

const db = await connect({
  path: './local-replica.db',
  url: 'http://localhost:8080',
});
Once connected, all sync operations (push, pull, checkpoint, stats) work exactly as described in the Usage guide.

Example: full local sync workflow

This example walks through a complete workflow — starting the server, writing data from one client, and syncing it to another.
1

1. Start the sync server

Open a terminal and start the server:
tursodb ./server.db --sync-server 0.0.0.0:8080
2

2. Write and push from Client A

import { connect } from '@tursodatabase/sync';

const clientA = await connect({
  path: './client-a.db',
  url: 'http://localhost:8080',
});

await clientA.exec("CREATE TABLE IF NOT EXISTS notes (id TEXT PRIMARY KEY, body TEXT)");
await clientA.exec("INSERT INTO notes VALUES ('n1', 'hello from client A')");

await clientA.push();
3

3. Pull from Client B

import { connect } from '@tursodatabase/sync';

const clientB = await connect({
  path: './client-b.db',
  url: 'http://localhost:8080',
});

const changed = await clientB.pull();
console.log('changes pulled:', changed);

const rows = await clientB.query("SELECT * FROM notes");
console.log(rows);
// [{ id: 'n1', body: 'hello from client A' }]