Documentation Index
Fetch the complete documentation index at: https://docs.turso.tech/llms.txt
Use this file to discover all available pages before exploring further.
Quickstart
Install
Add the Turso database package to your JavaScript project:npm i @tursodatabase/database
Connect
Here’s how you can connect to a local SQLite database:import { connect } from "@tursodatabase/database";
const db = await connect("sqlite.db");
Create table
Create a table for users:const createTable = db.prepare(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL
)
`);
createTable.run();
Insert data
Insert some data into the users table:const insertUser = db.prepare("INSERT INTO users (username) VALUES (?)");
insertUser.run("alice");
insertUser.run("bob");
Query data
Query all users from the table:const stmt = db.prepare("SELECT * FROM users");
const users = stmt.all();
console.log(users);
Examples
Explore these JavaScript examples to learn more about using Turso Database:
- Node — Node.js, local file database (no sync)
- Wasm + Vite — Browser (WASM), local database in the browser