Published on

Turso — SQLite at the Edge, Close to Every User

Authors

Introduction

Building global applications means accepting tradeoffs: centralized databases have consistency guarantees but high latency for distant users. Turso, built on libSQL (an open fork of SQLite), solves this by bringing databases to the edge. With embedded replicas, multi-tenant isolation, and TypeScript-first tooling, it''s reshaping how teams architect for scale.

What Is Turso?

Turso is a SQLite-compatible database platform that extends SQLite''s simplicity to distributed systems. Unlike traditional edge solutions that cache queries, Turso runs embedded read replicas locally, syncing writes back to a primary region.

The libSQL protocol enables this. When you write, changes propagate to replicas asynchronously. When you read, you hit the local replica—microseconds, not milliseconds.

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

const client = createClient({
  url: 'libsql://my-db-xxx.turso.io',
  authToken: process.env.TURSO_AUTH_TOKEN,
});

const result = await client.execute('SELECT * FROM users LIMIT 10');
console.log(result.rows);

Turso is managed—you don''t run Postgres instances or manage replicas. It''s also cheaper than traditional databases at scale because you''re not paying for redundant compute across regions.

Multi-Tenant Architecture

SaaS applications often isolate customer data in separate databases. This approach, called "database-per-tenant," has benefits: compliance, data isolation, independent scaling. But it''s operationally complex.

Turso supports database-per-tenant natively. Create one database per customer, keep them on the same plan, and let Turso handle replication.

// Create tenant database
const tenantDb = await createTursoDatabase({
  name: `tenant-${customerId}`,
  group: 'production',
});

// Read from local replica in user''s region
const replica = createClient({
  url: tenantDb.replicaUrl,
  authToken: tenantDb.token,
});

Each tenant gets isolated credentials and a dedicated database. Compliance teams sleep better. Scaling one tenant doesn''t affect others.

Embedded Replicas and Sync

The magic is embedded replicas. Your edge worker (Cloudflare, Deno Deploy, Vercel Edge) has a local SQLite file. On the first request, Turso syncs the schema and data. Subsequent reads are local—microseconds, not network round-trips.

Writes go to the primary region, then replicate back to embedded copies.

// Edge Function (Cloudflare Worker)
import { createClient } from '@libsql/client/web';

const client = createClient({
  url: 'libsql://my-db.turso.io',
  authToken: env.TURSO_AUTH_TOKEN,
});

export default {
  async fetch(request: Request) {
    // Read hits embedded replica
    const posts = await client.execute('SELECT * FROM posts WHERE userId = ?1', [userId]);
    return new Response(JSON.stringify(posts.rows));
  },
};

For write-heavy applications, Turso batches writes with async commit semantics. You trade immediate consistency for faster writes—acceptable for most use cases.

Schema Migrations with Drizzle

Managing schema changes across distributed databases requires a migration tool that understands Turso. Drizzle ORM integrates seamlessly.

import { drizzle } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';

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

const db = drizzle(client);

// Run migrations
await migrate(db, { migrationsFolder: './drizzle' });

Migrations run deterministically. For multi-tenant setups, you can apply the same migration to all tenant databases in a loop—fast because Turso handles replication.

Per-Region Latency Improvements

Benchmarks show the difference. A query to a central Postgres database in us-east-1 takes 80–120ms from Sydney. The same query to a Turso embedded replica takes 2–5ms.

That''s 20x faster. For applications where every millisecond matters—trading platforms, real-time dashboards—it''s transformative.

Writes still incur network latency to the primary, but reads dominate most workloads. 80% read, 20% write is typical. Turso optimizes the hot path.

Use Cases

SaaS per-tenant: Database isolation + global performance. Turso handles both.

Edge workers with real-time data: Cloudflare Workers + Turso replicas = sub-millisecond reads at the edge.

High-traffic read-heavy apps: News sites, dashboards, analytics UIs benefit from local replicas.

Pricing and Comparison

Turso charges per database and per row written. A startup with 10 databases at <1M rows/month pays roughly $50–100/month. PlanetScale and Neon (Postgres) cost more at equivalent scale because compute is region-locked.

FeatureTursoPlanetScaleNeon
Edge replicasYesNoNo
Database branchingNoYesYes
Multi-region readEmbeddedProxyNo
PricingPer rowPer MbpsPer hour

Turso wins on latency. PlanetScale and Neon win on schema branching (useful for preview environments).

Turso + Cloudflare Workers + Hono Stack

A realistic stack for 2026: Hono (lightweight web framework), Cloudflare Workers (compute at the edge), Turso (distributed database).

import { Hono } from 'hono';
import { createClient } from '@libsql/client/web';

const app = new Hono();
const client = createClient({
  url: 'libsql://my-db.turso.io',
  authToken: env.TURSO_AUTH_TOKEN,
});

app.get('/api/posts/:id', async (c) => {
  const id = c.req.param('id');
  const post = await client.execute('SELECT * FROM posts WHERE id = ?1', [id]);
  return c.json(post.rows[0]);
});

export default app;

Deploy with wrangler deploy. Requests route to the nearest Cloudflare edge node, read from the local Turso replica, and respond in milliseconds. No cold starts (Workers are prewarmed). No Postgres connection pools to manage.

This is the modern edge architecture. Turso makes it accessible.

Checklist

  • Set up a Turso database and create an auth token
  • Install @libsql/client and connect from Node.js or edge runtime
  • Design your schema for multi-tenant isolation if needed
  • Test write latency to the primary region
  • Deploy an edge function that reads from an embedded replica
  • Benchmark query performance (measure embedded vs network)
  • Set up migrations with Drizzle
  • Monitor replication lag with Turso dashboards

Conclusion

Turso eliminates the latency penalty of global databases. By running replicas at the edge, it makes sub-millisecond reads accessible to every user, regardless of geography. For SaaS teams, it simplifies multi-tenant architecture. For edge-first applications, it''s a natural fit.

The SQLite ecosystem is mature and familiar. Turso just removes the geographic constraints. If your application crosses borders, it''s worth evaluating.