Registry / database / sqlite-wasm-wasi

sqlite-wasm-wasi

JSON →
library0.6.0jsnpmunverified

SQLite database library for JavaScript/TypeScript environments that support WASM and WASI, such as Node.js with wasmtime or similar runtimes. Version 0.6.0 provides a synchronous API similar to better-sqlite3, but runs entirely in WebAssembly without native Node.js addons. It includes prepared statements, transactions, and supports BigInt for large integers. The package requires a separate `component.wasm` file that ships with the npm package, making it easy to integrate. Unlike better-sqlite3, it does not depend on native compilation and can run in any WASI-capable runtime. Development is active but early-stage, with regular releases.

npm install sqlite-wasm-wasi
INSTALL
IMPORT
SIG · SQLITE-WASM-WASI
S
sqlite-wasm-wasi
databasejavascriptv0.6.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

open
import { open } from 'sqlite-wasm-wasi'
const { open } = require('sqlite-wasm-wasi')
Package is ESM-only; CommonJS require will not work.
Database
import { Database } from 'sqlite-wasm-wasi'
import Database from 'sqlite-wasm-wasi'
Database is a named export, not a default export.
Statement
import type { Statement } from 'sqlite-wasm-wasi'
Statement is a class returned by db.prepare() and is not directly importable; use type import for TypeScript.

Opens an in-memory database, creates a table, inserts two rows, queries them, and closes the database.

import { open } from 'sqlite-wasm-wasi'; const db = open(':memory:'); db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)'); const insert = db.prepare('INSERT INTO users (name, email) VALUES (?, ?)'); insert.run(['Alice', 'alice@example.com']); insert.run(['Bob', 'bob@example.com']); const select = db.prepare('SELECT * FROM users WHERE id = ?'); const row = select.one([1]); console.log(row); // { id: 1n, name: 'Alice', email: 'alice@example.com' } const all = db.prepare('SELECT * FROM users').all(); console.log(all); // [{ id: 1n, name: 'Alice', email: 'alice@example.com' }, { id: 2n, name: 'Bob', email: 'bob@example.com' }] db.close();
Debug
Known issues
gotchaPrepared statements must be released manually to avoid memory leaks in long-running applications.
fix
Call stmt.release() when done with a statement, or use db.prepare('sql').run(...) for single-use.
affects: >=0.0.0
gotchaThe open() function defaults to 'unix-dotfile' VFS, which avoids flock() system calls. On some platforms, this may cause concurrency issues.
fix
Specify a different VFS via options if flock() behavior is needed.
affects: >=0.0.0
gotchaThe package requires a separate component.wasm file. If the file is missing or not copied, the library will not work at runtime.
fix
Ensure component.wasm is present in node_modules/sqlite-wasm-wasi/dist/ after install, or copy it to your deployment.
affects: >=0.0.0
breakingVersion 0.6.0 may not be compatible with older WASI runtimes due to internal changes.
fix
Update your WASI runtime (e.g., wasmtime) to the latest version.
affects: >=0.6.0
Errors
Common errors & fixes
Error: Cannot find module 'sqlite-wasm-wasi'
Package not installed or not in node_modules.
fix
Run npm install sqlite-wasm-wasi
TypeError: db.prepare is not a function
Incorrect import; using default import instead of named import.
fix
Change to import { open } from 'sqlite-wasm-wasi'
RuntimeError: memory access out of bounds
Missing or corrupted component.wasm file.
fix
Ensure component.wasm exists in node_modules/sqlite-wasm-wasi/dist/ and is the correct version.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
12
Meta
2
OpenAI (training)
2
Resources
sqlite-wasm-wasi — npm install sqlite-wasm-wasi · libregistry