Guide to setting up and using Turso Cloud
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:
| The next command will open your browser to sign up:
Now create your first database with the name my-db:
You can inspect your new database using the following command:
Congratulations, you created a database! Now connect to it with the shell command:
Replace my-db with the name of your database if you named it differently.
Now create a table for users using SQL:
(
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:
Get the database authentication token:
Assign credentials to environment variables inside .env:
TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=Install dependency:
Connect to your database:
;
const conn = url: process.env.,
authToken: process.env.,
});Execute a query using SQL
const stmt = await conn.;
const rows = await stmt.;If you need to use placeholders for values, you can do that:
const stmt = await conn.;
const row = await stmt.;