bun:sqlite in Bun
From the Bun cheat sheet ยท SQLite & Database ยท verified Jul 2026
bun:sqlite
Use the built-in SQLite database for fast local storage
typescript
import { Database } from "bun:sqlite";
const db = new Database("app.db");
db.exec(`CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
email TEXT UNIQUE
)`);
const insert = db.prepare("INSERT INTO users (name, email) VALUES (?, ?)");
insert.run("John", "john@test.com");
const users = db.query("SELECT * FROM users").all();๐ก bun:sqlite is built into Bun โ no npm install needed, 3-6x faster than better-sqlite3
โก Use db.transaction() for batch inserts โ wraps everything in a single atomic operation
๐ Always use prepared statements with ? or $name parameters to prevent SQL injection
๐ข Enable WAL mode for better performance with concurrent reads and writes
sqlitedatabasesql
Continue with Bun
Save the full cheat sheet or work through every related task.