Files
turso/sync/javascript
Pekka Enberg adca9e4c70 Merge 'introduce package.json for separate *-browser package (both database and sync)' from Nikita Sivukhin
This PR introduces separate `package.browser.json` file for `*-browser`
npm packages (`@tursodatabase/sync-browser` and
`@tursodatabase/database-browser`).
The packages are nearly identical and the only change is `package.json`
content (browser package mentions only WASM optional dependency which
shouldn't confuse NPM and force it to download WASM dep package instead
of native one).
Due to that, innocent "hack" is implemented which swap `package.json`
with `package.browser.json` before publish of `browser` package.

Closes #2906
2025-09-04 11:40:34 +03:00
..
2025-08-27 15:51:29 +04:00
2025-08-27 15:30:00 +04:00
2025-08-27 15:30:00 +04:00
2025-09-03 17:57:15 +04:00
2025-08-27 15:30:00 +04:00
2025-08-27 15:30:00 +04:00

Turso Sync for JavaScript

npm

Chat with other users of Turso on Discord


About

This package is for syncing local Turso databases to the Turso Cloud and back.

⚠️ Warning: This software is ALPHA, only use for development, testing, and experimentation. We are working to make it production ready, but do not use it for critical data right now.

Installation

npm install @tursodatabase/sync

Getting Started

To sync a database hosted at Turso Cloud:

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

const db = await connect({
    path: 'local.db',                // path used as a prefix for local files created by sync-engine
    url: 'https://<db>.turso.io',    // URL of the remote database: turso db show <db>
    authToken: '...',                // auth token issued from the Turso Cloud: turso db tokens create <db>
    clientName: 'turso-sync-example' // arbitrary client name
});

// db has same functions as Database class from @tursodatabase/database package but adds few more methods for sync:
await db.pull(); // pull changes from the remote
await db.push(); // push changes to the remote
await db.sync(); // pull & push changes

License

This project is licensed under the MIT license.

Support