{"id":46499,"library":"sqlite-wasm-cipher","title":"sqlite-wasm-cipher","description":"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.","status":"active","version":"2.2.4","language":"javascript","source_language":"en","source_url":"https://github.com/kat-tax/sqlite-wasm-cipher","tags":["javascript","sqlite","sqlite3","sqlite-wasm","sqlite3-wasm","sqlite-wasm-cipher","sqlite3-multiple-ciphers","webassembly","cipher","typescript"],"install":[{"cmd":"npm install sqlite-wasm-cipher","lang":"bash","label":"npm"},{"cmd":"yarn add sqlite-wasm-cipher","lang":"bash","label":"yarn"},{"cmd":"pnpm add sqlite-wasm-cipher","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is ESM-only. Default export is the initializer function (async).","wrong":"const initSqlite = require('sqlite-wasm-cipher')","symbol":"default","correct":"import initSqlite from 'sqlite-wasm-cipher'"},{"note":"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.","wrong":"import { sqlite3 } from 'sqlite-wasm-cipher' (wrong named export name; the named export is 'SQLite3')","symbol":"sqlite3","correct":"const db = await initSqlite({ locateFile: file => file }); const sqlite3 = db;\n// or\nimport { SQLite3 } from 'sqlite-wasm-cipher'"},{"note":"Available as named export; less common than using the default async initializer.","wrong":"import SQLite3 from 'sqlite-wasm-cipher' (default is a function, not the class; for direct class use named import)","symbol":"SQLite3","correct":"import { SQLite3 } from 'sqlite-wasm-cipher'"}],"quickstart":{"code":"import initSqlite from 'sqlite-wasm-cipher';\n\nconst sqlite3 = await initSqlite({\n  locateFile: (file) => file\n});\n\nconst db = new sqlite3.oo1.DB(':memory:');\ndb.exec('CREATE TABLE IF NOT EXISTS test (id, info)');\ndb.exec('INSERT INTO test VALUES (1, \"hello\")');\nconst stmt = db.prepare('SELECT * FROM test');\nwhile (stmt.step()) {\n  console.log(stmt.getAsObject());\n}\nstmt.free();\ndb.close();","lang":"typescript","description":"Initialize SQLite with ciphers, create an in-memory database, execute SQL, and iterate over results."},"warnings":[{"fix":"Use 'import' syntax or set type: 'module' in package.json; for CommonJS, use dynamic import: const initSqlite = (await import('sqlite-wasm-cipher')).default;","message":"ESM-only package; using require() will fail. Must use dynamic import or ESM module type.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Change import to default async function call: const db = await initSqlite(...);","message":"Version 2.0 renamed default export from 'SQLite' to initSqlite-like function. Old code using 'import SQLite from ...' no longer works.","severity":"breaking","affected_versions":"<2.0"},{"fix":"Always provide locateFile: file => '/path/to/' + file in init options.","message":"Direct access to 'locateFile' default URL is deprecated; future versions will require explicit locateFile option.","severity":"deprecated","affected_versions":">=2.2.0"},{"fix":"Use non-OPFS mode or fallback to memory/IDBFS in non-supporting environments.","message":"OPFS (Origin Private FileSystem) requires secure context (HTTPS or localhost) and is currently only available in Chromium browsers.","severity":"gotcha","affected_versions":">=2.0"},{"fix":"Use the default main export which includes all ciphers. For custom, refer to npm package variants.","message":"Ciphers require specific WASM build; the default build includes multiple ciphers, but custom builds may omit some. Check available build variants.","severity":"gotcha","affected_versions":">=2.0"}],"env_vars":null,"search_vec":"'2.2.4':17 'ae':26 'allow':19 'browser':32 'build':62 'built':49 'built-in':48 'chacha20':27 'cipher':4,14,51,79,83,85 'commonj':41 'differenti':43 'encrypt':25 'es':10 'esm':37 'etc':28 'filesystem':56 'import':38 'integr':57 'javascript':67 'key':42 'modul':11 'month':66 'multipl':13,82 'node.js':30 'opf':53 'origin':54 'privat':55 'provid':36 'publish':65 'raw':45 'requir':64 'sqlite':2,5,23,46,68,71,77 'sqlite-wasm':70 'sqlite-wasm-ciph':1,76 'sqlite3':69,74,81 'sqlite3-multiple-ciphers':80 'sqlite3-wasm':73 'stabl':18 'support':15,52 'tool':63 'type':59 'typescript':58,86 'use':22 'version':16 'via':33 'vs':44 'wasm':3,6,47,72,75,78 'webassembl':34,84 'wrap':7","created_at":"2026-06-07T13:00:13.076633+00:00","updated_at":"2026-06-07T13:00:13.076633+00:00","problems":[{"fix":"Switch to ESM: set type:'module' in package.json and use import, or use dynamic import: const mod = await import('sqlite-wasm-cipher');","cause":"Using require() in a CommonJS context.","error":"Error: The module 'sqlite-wasm-cipher' is not a CommonJS module; use import instead of require."},{"fix":"Use: import initSqlite from 'sqlite-wasm-cipher'; or use default from dynamic import.","cause":"Importing default incorrectly (e.g., using named import for default).","error":"TypeError: initSqlite is not a function"},{"fix":"Await initSqlite() and use the returned object, e.g.: const sqlite3 = await initSqlite(...); then sqlite3.oo1.DB.","cause":"Using the sqlite3 object before async init completes, or using wrong symbol.","error":"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'oo1')"},{"fix":"Ensure file path is correct or use ':memory:' for testing.","cause":"Accessing a non-existent or invalid database file, or using OPFS file handle incorrectly.","error":"Error: SQLITE_NOTADB: file is not a database"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/kat-tax/sqlite-wasm-cipher#readme","github":"https://github.com/kat-tax/sqlite-wasm-cipher","docs":null,"changelog":null,"pypi":null,"npm":"sqlite-wasm-cipher","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}