SQLite is great but local-only. Turso makes SQLite distributed, replicated, and edge-ready — with a generous free tier.
What is Turso?
Turso is a distributed database built on libSQL (an open-source fork of SQLite). It gives you SQLite's simplicity with edge replication and multi-tenancy.
Free Tier
- 9 GB total storage
- 500 databases
- 25 billion row reads/month
- 100 million row writes/month
- 3 locations
Quick Start
# Install CLI
brew install tursodatabase/tap/turso
# Login
turso auth login
# Create database
turso db create my-app
# Get connection URL
turso db show my-app --url
turso db tokens create my-app
Connect from TypeScript
bun add @libsql/client
import { createClient } from "@libsql/client";
const db = createClient({
url: process.env.TURSO_URL!,
authToken: process.env.TURSO_TOKEN!,
});
// Create table
await db.execute(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Insert
await db.execute({
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
args: ["Alice", "alice@example.com"],
});
// Query
const result = await db.execute("SELECT * FROM users");
for (const row of result.rows) {
console.log(row.name, row.email);
}
// Batch (transaction)
await db.batch([
{ sql: "INSERT INTO users (name, email) VALUES (?, ?)", args: ["Bob", "bob@example.com"] },
{ sql: "INSERT INTO users (name, email) VALUES (?, ?)", args: ["Carol", "carol@example.com"] },
], "write");
With Drizzle ORM
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";
const client = createClient({
url: process.env.TURSO_URL!,
authToken: process.env.TURSO_TOKEN!,
});
const db = drizzle(client);
Embedded Replicas (Offline-First)
import { createClient } from "@libsql/client";
const db = createClient({
url: "file:local-replica.db",
syncUrl: process.env.TURSO_URL!,
authToken: process.env.TURSO_TOKEN!,
});
// Reads are instant (local SQLite)
const users = await db.execute("SELECT * FROM users");
// Sync with remote when ready
await db.sync();
This gives you local-first reads with cloud sync. Perfect for edge computing.
Multi-Tenant (Database per Tenant)
# Create a database for each tenant
turso db create tenant-acme --group default
turso db create tenant-globex --group default
With 500 free databases, you can have 500 tenants on the free tier.
Turso vs Alternatives
| Feature | Turso | Neon | PlanetScale | D1 |
|---|---|---|---|---|
| Engine | libSQL (SQLite) | PostgreSQL | MySQL | SQLite |
| Edge Replicas | Yes | No | No | Yes |
| Embedded | Yes | No | No | No |
| Multi-tenant | 500 DBs free | 1 project | 1 DB | Unlimited |
| Offline-first | Yes | No | No | No |
Need to populate your database with web data? Check out my Apify actors — scrape and load data into Turso. For custom solutions, email spinov001@gmail.com.
Top comments (0)