What is Turso?
Turso is a distributed SQLite database built on libSQL (their open-source fork of SQLite). It runs your database at the edge — replicating data to 30+ locations worldwide — so reads are always fast, no matter where your users are.
Why Turso?
- Free tier — 9GB storage, 500 databases, 25 billion row reads/month
- Edge replicas — data replicated to 30+ global locations
- Embedded replicas — sync database INTO your app for zero-latency reads
- SQLite compatible — same SQL, same tools, same ecosystem
- Multi-tenancy — 500 databases on free tier (one per customer)
Quick Start
# Install Turso CLI
curl -sSfL https://get.tur.so/install.sh | bash
# Create database
turso db create my-app
# Get connection URL
turso db show my-app --url
# libsql://my-app-username.turso.io
# Get auth token
turso db tokens create my-app
import { createClient } from '@libsql/client';
const db = createClient({
url: 'libsql://my-app-username.turso.io',
authToken: 'your-token'
});
// Create table
await db.execute(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
email TEXT UNIQUE NOT NULL,
name TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Insert
await db.execute({
sql: 'INSERT INTO users (email, name) VALUES (?, ?)',
args: ['alex@example.com', 'Alex']
});
// Query
const result = await db.execute('SELECT * FROM users WHERE email = ?', ['alex@example.com']);
console.log(result.rows[0]);
Embedded Replicas (Zero-Latency Reads)
import { createClient } from '@libsql/client';
// Sync a local copy of the database INTO your app
const db = createClient({
url: 'file:local-replica.db', // Local SQLite file
syncUrl: 'libsql://my-app-username.turso.io', // Remote primary
authToken: 'your-token',
syncInterval: 60 // Sync every 60 seconds
});
// Reads are instant (local file)
const users = await db.execute('SELECT * FROM users');
// Writes go to primary, then sync back
await db.execute('INSERT INTO users (email) VALUES (?)', ['new@example.com']);
await db.sync(); // Or wait for auto-sync
Multi-Tenant Architecture
// Create a database per customer
const customerDb = createClient({
url: `libsql://customer-${customerId}.turso.io`,
authToken: getTokenForCustomer(customerId)
});
// Each customer has their own isolated database
// Turso free tier: 500 databases = 500 customers for free
Use with Drizzle ORM
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
const client = createClient({ url: TURSO_URL, authToken: TURSO_TOKEN });
const db = drizzle(client);
const users = await db.select().from(usersTable).where(eq(usersTable.active, true));
Turso vs Alternatives
| Feature | Turso | Neon | Supabase | PlanetScale |
|---|---|---|---|---|
| Engine | SQLite | PostgreSQL | PostgreSQL | MySQL |
| Free DBs | 500 | 1 | 2 | Deprecated |
| Edge replicas | 30+ locations | Read replicas | None | None |
| Embedded replica | Yes | No | No | No |
| Storage free | 9GB | 0.5GB | 500MB | N/A |
| Multi-tenant | Native | Manual | Manual | Branching |
Real-World Impact
A SaaS analytics tool needed per-customer databases with global access. Traditional approach: PostgreSQL per customer = $7/month/customer = unsustainable at scale. With Turso: SQLite per customer, embedded replicas in the edge function, reads under 1ms. Cost at 200 customers: $0 (free tier). Same setup in PostgreSQL would cost $1,400/month.
Building multi-tenant or edge applications? I help teams architect globally distributed data systems. Contact spinov001@gmail.com or explore my data tools on Apify.
Top comments (0)