DEV Community

Alex Spinov
Alex Spinov

Posted on

Turso Has a Free API — Edge SQLite Database With 9GB Storage and 500M Rows Read

SQLite at the Edge, For Free

Turso gives you a managed SQLite database that runs at the edge (35+ locations). Free tier: 9GB storage, 500M rows read/month, 25M rows written/month.

Setup

# Install CLI
curl -sSfL https://get.tur.so/install.sh | bash
turso auth login
turso db create my-app-db
turso db tokens create my-app-db
Enter fullscreen mode Exit fullscreen mode

JavaScript Client

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

const db = createClient({
  url: "libsql://my-app-db-username.turso.io",
  authToken: "your-token"
});

// Create table
await db.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");

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

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

Python Client

import libsql_experimental as libsql

conn = libsql.connect("my-app-db-username.turso.io", auth_token="your-token")
cursor = conn.cursor()

cursor.execute("SELECT * FROM users WHERE name LIKE ?", ("%John%",))
for row in cursor.fetchall():
    print(row)
Enter fullscreen mode Exit fullscreen mode

Embedded Replicas (Offline-First)

const db = createClient({
  url: "file:local-replica.db",
  syncUrl: "libsql://my-app-db-username.turso.io",
  authToken: "your-token"
});

// Sync with remote
await db.sync();

// Now queries hit local file - instant!
const result = await db.execute("SELECT * FROM users");
Enter fullscreen mode Exit fullscreen mode

Turso vs Alternatives

Feature Turso PlanetScale Neon Supabase
Database SQLite MySQL Postgres Postgres
Free storage 9GB 5GB 0.5GB 500MB
Edge replicas Yes No No No
Offline mode Yes No No No
Free reads 500M/mo 1B/mo Varies Unlimited

Turso wins on edge performance and offline capabilities.


More | GitHub


More from me: 10 Dev Tools I Use Daily | 77 Scrapers on a Schedule | 150+ Free APIs

Top comments (0)