sqlfu is a SQLite-first toolkit built around one idea: SQL should be the source language for your data layer. Schema lives inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/iterate/sqlfu/llms.txt
Use this file to discover all available pages before exploring further.
definitions.sql, migrations are SQL files, queries are checked-in .sql files, and TypeScript wrappers are generated automatically. You write SQL; sqlfu handles the rest.
Get started
Build a posts app from scratch — schema, migrations, typed queries — in under ten minutes.
Configuration
Set up
sqlfu.config.ts with your database, migrations, and query directories.Runtime client
Learn the shared
Client interface and how sync adapters stay sync.Adapters
Copy-paste snippets for Node, Bun, Turso, D1, Durable Objects, Expo, and more.
Core capabilities
SQL migrations
Schema diff engine turns
definitions.sql changes into reviewable migration files.Type generation
.sql query files become TypeScript wrappers with inferred params and result rows.Observability
Route query names to OpenTelemetry spans, Sentry, PostHog, and Datadog with one hook.
Runtime validation
Opt into zod, valibot, arktype, or zod-mini validation baked into generated wrappers.
SQL formatter
Opinionated SQLite formatter — CLI, ESLint rule, or programmatic API.
Lint plugin
ESLint rules that enforce SQL-first conventions and catch stale generated types.
How it works
sqlfu organizes your data layer into four artifacts:definitions.sql— the schema you want right nowmigrations/— the ordered history of schema changessql/— your checked-in query filessql/.generated/— TypeScript wrappers generated from your queries
Define your schema
Write your desired schema in
definitions.sql. This is the single source of truth.Draft a migration
Run
sqlfu draft. sqlfu diffs your schema against migration history and writes the next migration file for you to review.Generate typed wrappers
Run
sqlfu generate. Each .sql query file becomes a TypeScript function with typed params and result rows.Platform guides
Node.js
Use
node:sqlite (Node 22+) or better-sqlite3 for local development.Cloudflare D1
Connect sqlfu to a deployed D1 database via the HTTP API.
Durable Objects
Run sqlfu migrations at startup inside every Durable Object instance.
Turso / libSQL
Local embedded or remote Turso Cloud with the same typed client surface.