VOOZH about

URL: https://dev.to/0012303/turso-has-a-free-edge-sqlite-database-that-puts-data-closer-to-users-4c38

⇱ Turso Has a Free Edge SQLite Database That Puts Data Closer to Users - DEV Community


Centralized databases add latency. Turso replicates your SQLite database to 35+ edge locations worldwide — your data is always close to your users.

What Is Turso?

Turso is built on libSQL (a fork of SQLite created by the Turso team). It takes SQLite and adds:

  • Multi-region replication
  • HTTP API (works from serverless/edge)
  • Embedded replicas (sync to local SQLite)
  • Branching (like git for databases)

Free Tier

  • 9GB total storage
  • 500 databases
  • 25 billion row reads/month
  • 50 million row writes/month
  • 3 locations

Getting Started

# Install CLI
curl -sSfL https://get.tur.so/install.sh | bash
turso auth login

# Create database (replicated globally)
turso db create my-app
turso db show my-app --url
# → libsql://my-app-username.turso.io

# Create auth token
turso db tokens create my-app

Use with Drizzle ORM

import { drizzle } from "drizzle-orm/libsql";

const db = drizzle({
 connection: {
 url: process.env.TURSO_URL,
 authToken: process.env.TURSO_TOKEN,
 },
});

// Same Drizzle API — queries hit nearest replica
const users = await db.select().from(usersTable).limit(10);

Embedded Replicas (The Killer Feature)

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

const client = createClient({
 url: "file:local-replica.db", // Local SQLite file
 syncUrl: process.env.TURSO_URL, // Remote primary
 authToken: process.env.TURSO_TOKEN,
 syncInterval: 60, // Sync every 60 seconds
});

// Reads: instant (local SQLite, 0ms latency)
const result = await client.execute("SELECT * FROM users WHERE id = ?", [1]);

// Writes: go to primary, then sync back
await client.execute("INSERT INTO users (name) VALUES (?)", ["Alice"]);

Your app reads from a local SQLite file (microsecond latency) and syncs with the cloud primary. Best of both worlds.

Database Branching

# Create a branch for development
turso db create my-app-dev --from-db my-app

# Test migrations on the branch
turso db shell my-app-dev "ALTER TABLE users ADD COLUMN bio TEXT"

# If it works, apply to production
turso db shell my-app "ALTER TABLE users ADD COLUMN bio TEXT"

Why Turso Over Alternatives

Turso PlanetScale Neon Supabase
Engine SQLite (libSQL) MySQL PostgreSQL PostgreSQL
Edge replicas Yes (35+) No Read replicas No
Embedded replica Yes (local file) No No No
Branching Yes Yes Yes No
Serverless Yes Yes Yes Yes
Free tier Generous Removed Generous Generous

Perfect For

  • Edge/serverless apps — zero cold start, data at the edge
  • Mobile apps — local SQLite + cloud sync
  • Multi-tenant SaaS — one database per tenant (500 free!)
  • Read-heavy workloads — local reads, remote writes

Need edge-deployed data solutions? I build APIs and scraping tools. Email spinov001@gmail.com or explore my Apify developer tools.