DEV Community

Alex Spinov
Alex Spinov

Posted on

Turso CLI Has a Free API That Most Developers Dont Know About

Turso is SQLite for production — edge-hosted, replicated, and managed. The CLI lets you manage databases, create replicas, and run queries.

Setup

brew install tursodatabase/tap/turso
turso auth login
turso db create my-app
turso db show my-app  # Shows URL and token
Enter fullscreen mode Exit fullscreen mode

Database Operations

# Create database with location
turso db create my-app --location iad

# Add replicas
turso db replicate my-app cdg  # Paris
turso db replicate my-app nrt  # Tokyo

# Shell
turso db shell my-app
> CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);
> INSERT INTO users (name, email) VALUES (Alice, alice@example.com);
> SELECT * FROM users;
Enter fullscreen mode Exit fullscreen mode

Client SDK

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

const db = createClient({
  url: process.env.TURSO_DATABASE_URL,
  authToken: process.env.TURSO_AUTH_TOKEN
});

const result = await db.execute("SELECT * FROM users WHERE id = ?", [1]);
const batch = await db.batch([
  "INSERT INTO users (name) VALUES (Bob)",
  "SELECT last_insert_rowid()"
]);
Enter fullscreen mode Exit fullscreen mode

Key Features

  • Edge SQLite with global replicas
  • Embedded replicas (local copy)
  • Free tier: 500 databases, 9GB
  • Compatible with SQLite ecosystem
  • Drizzle ORM integration

Need to scrape or monitor web data at scale? Check out my web scraping actors on Apify or email spinov001@gmail.com for custom solutions.

Top comments (0)