DEV Community

Alex Spinov
Alex Spinov

Posted on

Turso Has a Free API: SQLite for the Edge With Built-in Replication

Turso is a SQLite-compatible database built on libSQL that replicates globally. Your data lives at the edge, close to your users, with read latency under 10ms worldwide.

Why Turso Matters

SQLite is the most deployed database but cannot replicate across servers. Turso adds multi-region replication, branching, and a managed service while keeping full SQLite compatibility.

What you get for free:

  • Full SQLite compatibility
  • Global replication to 30+ locations
  • Embedded replicas (sync database to your app)
  • Database branching (like git branches for data)
  • 500 databases, 9GB storage on free tier
  • Works with any SQLite client library

Quick Start

curl -sSfL https://get.tur.so/install.sh | bash
turso db create my-app
turso db shell my-app
turso db show my-app --url
turso db tokens create my-app
Enter fullscreen mode Exit fullscreen mode

Node.js Client

import { createClient } from "@libsql/client";

const db = createClient({
  url: "libsql://my-app-user.turso.io",
  authToken: process.env.TURSO_AUTH_TOKEN,
});

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
  )
`);

await db.execute({
  sql: "INSERT INTO users (name, email) VALUES (?, ?)",
  args: ["Alice", "alice@example.com"],
});

const result = await db.execute("SELECT * FROM users");
console.log(result.rows);
Enter fullscreen mode Exit fullscreen mode

Embedded Replicas

const db = createClient({
  url: "file:local-replica.db",
  syncUrl: "libsql://my-app-user.turso.io",
  authToken: process.env.TURSO_AUTH_TOKEN,
});

// Reads are instant (local file)
const users = await db.execute("SELECT * FROM users");

// Writes sync to remote
await db.execute({
  sql: "INSERT INTO users (name, email) VALUES (?, ?)",
  args: ["Dave", "dave@example.com"],
});

await db.sync();
Enter fullscreen mode Exit fullscreen mode

Database Branching

turso db create my-app-staging --from-db my-app
turso db shell my-app-staging
# Same data as production — test migrations safely
Enter fullscreen mode Exit fullscreen mode

Latency Comparison

Database Read Latency (global) SQLite Compatible
Turso 1-10ms Yes
PlanetScale 10-50ms No (MySQL)
Supabase 20-100ms No (PostgreSQL)

Links


Building edge data applications? Check out my developer tools on Apify or email spinov001@gmail.com for custom solutions.

Top comments (0)