Guide to setting up and using Turso Cloud
On this page
Introduction
Turso is a cloud database platform built on libSQL, an open-source fork of SQLite.
It is designed for edge and serverless environments — each database is a lightweight SQLite file hosted on the cloud, accessible over HTTP from any runtime (Node.js, Deno, Bun, browsers, Cloudflare Workers, Netlify Edge Functions, etc.).
Key features:
- SQLite-compatible — standard SQL, no new query language to learn
- Serverless-first — connects over HTTP/WebSockets, no persistent connection needed
- Global replication — replicate databases closer to users with embedded replicas
- Free tier — generous limits for development and small projects
Cloud
Refer to the official Turso Cloud documentation for more information.
Quick Start
Install the Turso CLI using the following command:
curl -sSfL https://get.tur.so/install.sh | bashThe next command will open your browser to sign up:
turso auth signupNow create your first database with the name my-db:
turso db create my-dbYou can inspect your new database using the following command:
turso db show my-dbCongratulations, you created a database! Now connect to it with the shell command:
turso db shell my-dbReplace my-db with the name of your database if you named it differently.
Now create a table for users using SQL:
CREATE TABLE users ( ID INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT);Then insert a row into the users table:
INSERT INTO users (name) VALUES ('Iku');Finally, query for all users:
SELECT * FROM users;When you’re ready to move onto the next step, quit the shell:
.quitSDK
@tursodatabase/serverless is the recommended package for any application that connects to a remote Turso Cloud database over the network.
It uses only fetch — zero native dependencies, works everywhere.
You will need an existing database to continue. If you don’t have one, create one.
Get the database URL:
turso db show --url <database-name>Get the database authentication token:
turso db tokens create <database-name>Assign credentials to environment variables inside .env:
TURSO_DATABASE_URL=TURSO_AUTH_TOKEN=Install dependency:
deno add @tursodatabase/serverlessConnect to your database:
import { connect } from "@tursodatabase/serverless";
const conn = connect({ url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN,});Execute a query using SQL
const stmt = await conn.prepare("SELECT * FROM users");const rows = await stmt.all();If you need to use placeholders for values, you can do that:
const stmt = await conn.prepare("SELECT * FROM users WHERE id = ?");const row = await stmt.get([1]);