Documentation 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.
@sqlite.org/sqlite-wasm brings SQLite to the browser as a WebAssembly module. The createSqliteWasmClient adapter wraps an open sqlite-wasm database handle as an AsyncClient, giving you the same typed query surface you use on the server — just with promises at each call site.
Configure sqlfu
The browser cannot read migration files from disk at runtime — they must be bundled. Leave Generated wrappers are async by default, matching the
db out of the config; sqlfu uses definitions.sql for type generation and generates a migration bundle the app imports:sqlfu.config.ts
sqlite-wasm adapter.Write schema and queries
Add your schema to Add a query to
definitions.sql:definitions.sql
sql/queries.sql:sql/queries.sql
Draft and generate
Run the authoring commands on your development machine:
sqlfu generate writes TypeScript wrappers into sql/.generated/ and the migration bundle into migrations/.generated/migrations.ts. Both are committed to your repo and bundled into the browser app.OPFS vs. in-memory storage
- OPFS (persistent)
- In-memory
Use the
opfs VFS to persist data across page reloads. OPFS requires a secure context (HTTPS or localhost) and the page must be served with the following headers:Async behavior
@sqlite.org/sqlite-wasm is asynchronous. All generated wrappers and client.all(...) calls return promises:
Browser considerations
- The WASM binary is loaded asynchronously on first call to
sqlite3InitModule(). Call it once and reuse the returnedsqlite3object. - OPFS access requires both the
Cross-Origin-Opener-PolicyandCross-Origin-Embedder-Policyheaders. Missing headers will cause a runtime error when opening an OPFS-backed database. - The migration bundle (
migrations/.generated/migrations.ts) is idempotent and safe to run on every page load.
Read next
Adapters reference
The sqlite-wasm adapter snippet and the full compatibility matrix.
SQL migrations
Migration history, the generated bundle, and drift detection.