Turso is joining Supabase to give every agent its own database Read the news →

Turso for TypeScript

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.

Your first query takes three lines

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.

app.ts
Turso
import { connect } from "@tursodatabase/database";

const db = await connect("app.db");
const users = await db.prepare("SELECT * FROM users").all();

Where SQLite stops, Turso keeps going

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

Runs on Workers and Vercel Edge

@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.

worker.ts
Turso
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

Your app keeps working offline

@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.

sync.ts
Turso
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 changes

03

Many writers, one database

@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

writer 1
writer 2
writer 3
writer 4

Turso

writer 1
writer 2
writer 3
writer 4

Illustration of write timing, not a benchmark.

04

A database for every user, tenant or agent

@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.

tenants.ts
Turso
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;
}

Bring Drizzle

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 Drizzle
db.ts · drizzle-orm@rc
Turso
import { Database } from "@tursodatabase/database";
import { drizzle } from "drizzle-orm/tursodatabase/database";

const client = new Database("app.db");
export const db = drizzle({ client });
Also in Turso·Vector search · Encryption at rest with AEGIS and AES-GCM · Bring your own key on the Pro plan · Browser builds that store data in OPFS

Choose where your database lives

Embedded, hosted Cloud and Cloud BYOC are deployment choices — not a ladder of application maturity.

Turso embedded

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 file

Turso Cloud

Use 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 API

Turso Cloud BYOC

Use 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 team

Already in production, and moving fast

Turso 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

A stable edge driver

@tursodatabase/serverless uses fetch only, with no native dependencies. Check its release notes before upgrading.

Steady releases

Releases land every few weeks, and each one has moved the TypeScript packages forward, from the concurrent writes API to the latest performance work.

Questions TypeScript developers ask first

Which package should I start with?
For a local file, start with @tursodatabase/database. For a local copy that syncs, use @tursodatabase/sync. For remote queries, use @tursodatabase/serverless. For Drizzle or Prisma on Vercel, follow the documented @libsql/client integration.
Does it work on Cloudflare Workers?
Yes, through @tursodatabase/serverless, which uses fetch only and needs no native code.
Can I use concurrent writes on Turso Cloud?
Yes, in beta. Concurrent writes are available on Turso Cloud through the @tursodatabase packages.
Is it ready for production?
Yes. Turso is production ready and powers teams including Superhuman, Sauna.ai, CTO.new and Mastra. Features are production ready unless marked beta or experimental. Check the release notes for the package you use.
Can I move an existing SQLite database over?
Turso uses the SQLite query language and file format, so existing databases and queries carry over. One exception is that encrypted Turso databases cannot be opened by standard SQLite.
Can Turso run in my own cloud account?
Yes. Turso Cloud BYOC runs the same platform in your own AWS account, with the same APIs and SDKs. Your data stays in your account. Contact Turso to discuss your deployment.

Install a package and run your first query.

The free plan covers a real project. No credit card to start.

See all plans and pricing
100
databases
5 GB
storage
500M
row reads a month
10M
row writes a month