SQLite is the most deployed database in the world. But it only works on a single machine. You cannot share it across servers, replicate it globally, or use it in serverless functions.
Turso fixes this. It takes SQLite and makes it distributed, replicated, and edge-native — using libSQL, their open-source fork. The free tier gives you 9GB storage and 500 databases.
What You Get for Free
- 9 GB total storage — across all databases
- 500 databases — each with its own schema
- 3 locations — primary + 2 replicas
- Embedded replicas — in-process SQLite replica in your app
- 500M rows read/month — generous read quota
- 25M rows written/month — generous write quota
- libSQL — SQLite fork with ALTER COLUMN, RANDOM ROWID, HTTP API
Quick Start
1. Install CLI
# macOS
brew install tursodatabase/tap/turso
# Login
turso auth login
# Create database
turso db create mydb
# Get connection URL
turso db show mydb --url
turso db tokens create mydb
2. Node.js with @libsql/client
npm install @libsql/client
import { createClient } from "@libsql/client";
const db = createClient({
url: "libsql://mydb-YOUR_ORG.turso.io",
authToken: "YOUR_TOKEN",
});
// Create table
await db.execute(`
CREATE TABLE IF NOT EXISTS posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Insert
await db.execute({
sql: "INSERT INTO posts (title, content) VALUES (?, ?)",
args: ["Hello World", "This is my first post"],
});
// Query
const result = await db.execute("SELECT * FROM posts ORDER BY created_at DESC");
console.log(result.rows);
3. Python
pip install libsql-experimental
import libsql_experimental as libsql
conn = libsql.connect("mydb.db", sync_url="libsql://mydb-YOUR_ORG.turso.io", auth_token="YOUR_TOKEN")
conn.sync()
conn.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)")
conn.execute("INSERT INTO users (name, email) VALUES (?, ?)", ("Alex", "alex@example.com"))
conn.commit()
users = conn.execute("SELECT * FROM users").fetchall()
print(users)
4. Embedded Replicas (The Killer Feature)
import { createClient } from "@libsql/client";
// Embedded replica — SQLite runs IN your app process
// Reads are instant (local file), writes sync to Turso
const db = createClient({
url: "file:local-replica.db",
syncUrl: "libsql://mydb-YOUR_ORG.turso.io",
authToken: "YOUR_TOKEN",
syncInterval: 60, // sync every 60 seconds
});
// This read hits local SQLite — microsecond latency
const result = await db.execute("SELECT * FROM posts WHERE id = 1");
Zero-latency reads. Your database is literally in the same process as your app.
Real-World Use Case
A developer building a multi-tenant SaaS told me: "Each customer gets their own Turso database. 500 databases on the free tier means I can onboard 500 customers before paying anything. And embedded replicas mean my API responses went from 50ms to under 1ms for reads."
Free Plan Limits
| Feature | Free Tier |
|---|---|
| Storage | 9 GB total |
| Databases | 500 |
| Locations | 3 |
| Rows read | 500M/month |
| Rows written | 25M/month |
| Embedded replicas | Yes |
| Branching | No (paid) |
The Bottom Line
If you love SQLite but need it to work across servers, regions, or serverless functions — Turso is SQLite for the distributed web. Embedded replicas give you the best of both worlds: local speed with cloud durability.
Need to scrape data into SQLite? Check out my web scraping tools on Apify — extract data from any website and export as CSV/JSON.
Building something custom? Email me at spinov001@gmail.com
Top comments (0)