Registry / database / wa-sqlite

wa-sqlite

JSON →
library1.0.0jsnpmunverified

wa-sqlite is a WebAssembly build of SQLite that enables writing virtual filesystems and virtual table modules in JavaScript. The current stable version is 1.0.0. It provides both synchronous and asynchronous (using Asyncify) builds, with ESM modules as the default. Key differentiators include support for IndexedDB and Origin Private File System VFS implementations, allowing alternative browser storage options. The project ships TypeScript types and has a moderate release cadence. Unlike other SQLite WASM bindings, wa-sqlite focuses on extensibility via JavaScript-based VFS and virtual table modules.

npm install wa-sqlite
INSTALL
IMPORT
SIG · WA-SQLITE
W
wa-sqlite
databasejavascriptv1.0.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.

SQLiteESMFactory
import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs'
const SQLiteESMFactory = require('wa-sqlite')
Since v1.0.0, wa-sqlite is ESM-only; CommonJS require() will fail.
SQLite
import * as SQLite from 'wa-sqlite'
import { Factory } from 'wa-sqlite'
The main namespace exports all API functions; named export 'Factory' exists but is not the default.
Factory
const sqlite3 = SQLite.Factory(module)
const sqlite3 = new SQLite.Factory(module)
Factory is a function, not a constructor; calling with 'new' will throw an error.

Initializes wa-sqlite WASM module, opens a database, executes a query, and logs results.

import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs'; import * as SQLite from 'wa-sqlite'; async function hello() { const module = await SQLiteESMFactory(); const sqlite3 = SQLite.Factory(module); const db = await sqlite3.open_v2('myDB'); await sqlite3.exec(db, `SELECT 'Hello, world!'`, (row, columns) => { console.log(row); }); await sqlite3.close(db); } hello();
Debug
Known issues
gotchaThe async build requires Asyncify; synchronous builds are also available but cannot use async VFS.
fix
Use 'wa-sqlite/dist/wa-sqlite-async.mjs' for async features, or 'wa-sqlite/dist/wa-sqlite.mjs' for sync.
affects: >=1.0.0
breakingPre-built artifacts were previously in the 'buildless' branch; that branch is no longer maintained.
fix
Use the dist/ directory from the main branch or specify version >=1.0.0.
affects: <1.0.0
gotchaThe 'open_v2' function is async only in the async build; in the sync build it is synchronous.
fix
Check build type: use 'await' only with async build, omit 'await' with sync build.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'wa-sqlite'
Using require() with ESM-only package.
fix
Use ES module import syntax: import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
TypeError: SQLite.Factory is not a constructor
Calling Factory() with 'new' keyword.
fix
Remove 'new': const sqlite3 = SQLite.Factory(module);
TypeError: sqliet3.open_v2 is not a function
Using async build without awaiting init.
fix
Ensure module is awaited: const module = await SQLiteESMFactory();
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
wa-sqlite — npm install wa-sqlite · libregistry