Turso gives you SQLite at the edge with an HTTP API and native client libraries. Your data replicates globally with single-digit millisecond reads from any region.
Getting Started
npm install @libsql/client
import { createClient } from '@libsql/client';
const db = createClient({
url: 'libsql://your-db-name-org.turso.io',
authToken: 'your-token'
});
// Create table
await db.execute(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE
)
`);
// 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');
console.log(result.rows);
HTTP API
No SDK needed — just curl:
curl -X POST https://your-db-org.turso.io/v2/pipeline \
-H "Authorization: Bearer $TURSO_TOKEN" \
-H "Content-Type: application/json" \
-d '{"requests":[{"type":"execute","stmt":{"sql":"SELECT * FROM users"}}]}'
Embedded Replicas
Run a local SQLite replica that syncs with the edge:
const db = createClient({
url: 'file:local.db',
syncUrl: 'libsql://your-db-org.turso.io',
authToken: 'your-token'
});
await db.sync(); // Pull latest from edge
const result = await db.execute('SELECT * FROM users');
Batch Transactions
await db.batch([
{ sql: 'INSERT INTO orders (user_id, total) VALUES (?, ?)', args: [1, 99.99] },
{ sql: 'UPDATE users SET order_count = order_count + 1 WHERE id = ?', args: [1] }
], 'write');
Why This Matters
- Edge-first: Data in 30+ regions with <10ms reads
- SQLite compatibility: Use existing tools and knowledge
- Embedded replicas: Zero-latency reads for server apps
- Free tier: 9GB storage, 500M rows read/month
Need custom database tooling or data pipeline automation? I build developer tools. Check out my web scraping actors on Apify or reach out at spinov001@gmail.com for custom solutions.
Top comments (0)