Registry / database / sqlite-wasm-cipher

sqlite-wasm-cipher

JSON →
library2.2.4jsnpmunverified

SQLite Wasm wrapped as an ES Module with multiple ciphers support. Version 2.2.4 (stable) allows you to use SQLite with encryption (AES, ChaCha20, etc.) in Node.js and browsers via WebAssembly. It provides ESM imports only, no CommonJS. Key differentiator vs raw SQLite Wasm: built-in cipher support, OPFS (Origin Private FileSystem) integration, TypeScript types, and no build tool required. Published monthly.

npm install sqlite-wasm-cipher
INSTALL
IMPORT
SIG · SQLITE-WASM-CIPHER
S
sqlite-wasm-cipher
databasejavascriptv2.2.4
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.

default
import initSqlite from 'sqlite-wasm-cipher'
const initSqlite = require('sqlite-wasm-cipher')
This package is ESM-only. Default export is the initializer function (async).
sqlite3
const db = await initSqlite({ locateFile: file => file }); const sqlite3 = db; // or import { SQLite3 } from 'sqlite-wasm-cipher'
import { sqlite3 } from 'sqlite-wasm-cipher' (wrong named export name; the named export is 'SQLite3')
The module exports 'SQLite3' as a named export (capital S), not 'sqlite3'. But most users call the default init function and use the returned object.
SQLite3
import { SQLite3 } from 'sqlite-wasm-cipher'
import SQLite3 from 'sqlite-wasm-cipher' (default is a function, not the class; for direct class use named import)
Available as named export; less common than using the default async initializer.

Initialize SQLite with ciphers, create an in-memory database, execute SQL, and iterate over results.

import initSqlite from 'sqlite-wasm-cipher'; const sqlite3 = await initSqlite({ locateFile: (file) => file }); const db = new sqlite3.oo1.DB(':memory:'); db.exec('CREATE TABLE IF NOT EXISTS test (id, info)'); db.exec('INSERT INTO test VALUES (1, "hello")'); const stmt = db.prepare('SELECT * FROM test'); while (stmt.step()) { console.log(stmt.getAsObject()); } stmt.free(); db.close();
Debug
Known issues
gotchaESM-only package; using require() will fail. Must use dynamic import or ESM module type.
fix
Use 'import' syntax or set type: 'module' in package.json; for CommonJS, use dynamic import: const initSqlite = (await import('sqlite-wasm-cipher')).default;
affects: >=1.0
breakingVersion 2.0 renamed default export from 'SQLite' to initSqlite-like function. Old code using 'import SQLite from ...' no longer works.
fix
Change import to default async function call: const db = await initSqlite(...);
affects: <2.0
deprecatedDirect access to 'locateFile' default URL is deprecated; future versions will require explicit locateFile option.
fix
Always provide locateFile: file => '/path/to/' + file in init options.
affects: >=2.2.0
gotchaOPFS (Origin Private FileSystem) requires secure context (HTTPS or localhost) and is currently only available in Chromium browsers.
fix
Use non-OPFS mode or fallback to memory/IDBFS in non-supporting environments.
affects: >=2.0
gotchaCiphers require specific WASM build; the default build includes multiple ciphers, but custom builds may omit some. Check available build variants.
fix
Use the default main export which includes all ciphers. For custom, refer to npm package variants.
affects: >=2.0
Errors
Common errors & fixes
Error: The module 'sqlite-wasm-cipher' is not a CommonJS module; use import instead of require.
Using require() in a CommonJS context.
fix
Switch to ESM: set type:'module' in package.json and use import, or use dynamic import: const mod = await import('sqlite-wasm-cipher');
TypeError: initSqlite is not a function
Importing default incorrectly (e.g., using named import for default).
fix
Use: import initSqlite from 'sqlite-wasm-cipher'; or use default from dynamic import.
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'oo1')
Using the sqlite3 object before async init completes, or using wrong symbol.
fix
Await initSqlite() and use the returned object, e.g.: const sqlite3 = await initSqlite(...); then sqlite3.oo1.DB.
Error: SQLITE_NOTADB: file is not a database
Accessing a non-existent or invalid database file, or using OPFS file handle incorrectly.
fix
Ensure file path is correct or use ':memory:' for testing.
Upgrade
Version history
2.2.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
Meta
1
Amazon
1
OpenAI (training)
1
Resources
sqlite-wasm-cipher — npm install sqlite-wasm-cipher · libregistry