SQLite that runs everywhere your TypeScript does.
Turso is a SQLite-compatible database. Keep it as a file next to your Node.js code, sync it from React Native or the browser, or query it over fetch from Workers and edge functions. The SQL stays the same in every one.
$ npm install @tursodatabase/database
Packages on npm for Node.js, the edge, the browser and React Native. Open source under the MIT license.
Install the package, open a file and run SQL. Turso uses the SQLite query language and file format, so the queries and schemas you already write carry over. Where the database lives — Turso embedded, Turso Cloud or Turso Cloud BYOC — depends on where your code runs and where your data needs to stay. The SQL is the same in each case.
import { connect } from "@tursodatabase/database";
const db = await connect("app.db");
const users = await db.prepare("SELECT * FROM users").all();SQLite is the simplest database a TypeScript app can have, until the app needs the edge, offline sync, many writers or many tenants. At that point, teams usually switch databases or build the missing piece themselves. Turso handles each while keeping SQLite’s SQL and file format.
01
@tursodatabase/serverlessWith SQLiteSQLite drivers for Node.js load native binaries and expect a disk. Cloudflare Workers and other edge runtimes have neither, so the build fails or the file is gone on the next request.With Turso@tursodatabase/serverless talks to Turso Cloud with fetch only and has zero native dependencies. It runs on Workers, Vercel Edge, serverless functions and Node.js servers. Check the package release notes for the latest version.
import { connect } from "@tursodatabase/serverless";
const conn = connect({
url: process.env.TURSO_DATABASE_URL,
authToken: process.env.TURSO_AUTH_TOKEN,
});
const user = await conn
.prepare("SELECT * FROM users WHERE id = ?")
.get([123]);02
@tursodatabase/syncWith SQLiteA SQLite file lives on one device. Getting its changes to a server and back again means writing and maintaining your own sync layer.With Turso@tursodatabase/sync reads and writes a local file and syncs it with Turso Cloud. Call push() to send changes and pull() to fetch them, whenever your app decides. Use the dedicated React Native or WebAssembly package for those runtimes.
import { connect } from "@tursodatabase/sync";
const db = await connect({
path: "local.db",
url: "https://<db>.turso.io",
authToken: process.env.TURSO_AUTH_TOKEN,
clientName: "my-app",
});
await db.push(); // send local changes
await db.pull(); // fetch remote changes03
@tursodatabase/databaseWith SQLiteSQLite allows one writer at a time. Under load, every other write waits its turn behind a single lock.With TursoTurso adds concurrent writes, so transactions that touch different rows commit together. In @tursodatabase/database, run the work with db.transaction(fn).concurrent(). Under the hood that opens a BEGIN CONCURRENT transaction, so writers that touch different rows stop waiting on one lock. Concurrent writes on Turso Cloud are in beta.
SQLite
Turso
Illustration of write timing, not a benchmark.
04
@tursodatabase/apiWith SQLiteOne shared file mixes every customer together. Running thousands of separate files yourself means building and operating a platform.With TursoTurso Cloud creates a database with one API call, and the official @tursodatabase/api client makes that a few lines of TypeScript. The free plan includes 100 databases, and paid plans remove the cap.
import { createClient } from "@tursodatabase/api";
const turso = createClient({
org: process.env.TURSO_ORG,
token: process.env.TURSO_PLATFORM_TOKEN,
});
export async function createTenantDb(tenantId: string) {
const db = await turso.databases.create(`tenant-${tenantId}`, {
group: "default",
});
return db.hostname;
}Use Drizzle with the documented @libsql/client integration for Turso Cloud, including Vercel. The local @tursodatabase/database adapter is available in Drizzle’s release candidate. ORM support varies by driver; do not treat every package as interchangeable.
Read the Turso guide for Drizzleimport { Database } from "@tursodatabase/database";
import { drizzle } from "drizzle-orm/tursodatabase/database";
const client = new Database("app.db");
export const db = drizzle({ client });Embedded, hosted Cloud and Cloud BYOC are deployment choices — not a ladder of application maturity.
localUse it forA database file in the same process as your TypeScript code.Where it runsNode.js and Electron; WebAssembly builds for the browser.Connect with@tursodatabase/database · add sync when needed
Open a local database fileUse it forManaged databases for every user, tenant or agent, without operating a database platform.Where it runsHosted by Turso. Query remotely or sync a local copy next to your code.Connect with@tursodatabase/serverless or sync
Create databases through the APIUse it forThe same managed platform when data must stay in your own cloud account.Where it runsYour AWS account, in your chosen regions. The same APIs and SDKs apply.DeploymentBring Your Own Cloud
Talk to the Turso teamTurso powers teams including Superhuman, Sauna.ai, CTO.new and Mastra. Its open-source engine and TypeScript packages continue to develop together.
“Because we can branch and rollback databases quickly with just an API call, we can really scale our AI agents.”
Mike Soylu
Founder, Adaptive
@tursodatabase/serverless uses fetch only, with no native dependencies. Check its release notes before upgrading.
Releases land every few weeks, and each one has moved the TypeScript packages forward, from the concurrent writes API to the latest performance work.
The free plan covers a real project. No credit card to start.
See all plans and pricing