Registry / database / sqlite-vec-wasm

sqlite-vec-wasm

JSON →
library0.1.0jsnpmunverified

Precompiled SQLite 3.50.4 integrated with sqlite-vec v0.1.6 as a WebAssembly module for browser and Node.js environments. This package provides full SQLite WASM API (OO1 wrapper), worker thread support, and OPFS VFS, with sqlite-vec auto-initialized for vector similarity search. Built using the official SQLite WASM build system, it includes FTS5, R-Tree, JSON1 extensions and is served as ESM/bundler-friendly builds. Version 0.1.0 targets Node >=18 and modern browsers with COOP/COEP headers required for SharedArrayBuffer features. Key differentiator: no server needed for vector search in the browser, pure WASM with auto-init.

npm install sqlite-vec-wasm
INSTALL
IMPORT
SIG · SQLITE-VEC-WASM
S
sqlite-vec-wasm
databasejavascriptv0.1.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.

sqlite3InitModule
import sqlite3InitModule from 'sqlite-vec-wasm/dist/sqlite3.mjs';
Default import of the async init function. Use .mjs for ES modules.
sqlite3
const { sqlite3 } = await import('sqlite-vec-wasm/dist/sqlite3.mjs');
Alternative: use dynamic import and destructure the module object after init.
oo1.DB
const db = new sqlite3.oo1.DB();
const db = new sqlite3.oo1.Database();
The OO1 wrapper uses 'DB' not 'Database'. sqlite3 is the top-level module object.

Demonstrates initializing sqlite3 wasm module, creating a vec0 virtual table, inserting vectors, and querying for similar vectors using sqlite-vec.

// Ensure served with COOP/COEP headers (e.g., node server.js) import sqlite3InitModule from 'sqlite-vec-wasm/dist/sqlite3.mjs'; async function main() { const sqlite3 = await sqlite3InitModule(); // Open in-memory database const db = new sqlite3.oo1.DB(); // sqlite-vec is auto-initialized db.exec(`CREATE VIRTUAL TABLE vec_items USING vec0(embedding float[4])`); const insertStmt = db.prepare("INSERT INTO vec_items(rowid, embedding) VALUES (?, ?)"); insertStmt.bind(1, [1,2,3,4]); // example vector insertStmt.step(); insertStmt.free(); // Search const rows = db.exec({ sql: `SELECT rowid, distance FROM vec_items WHERE embedding MATCH '[1,2,3,4]' ORDER BY distance LIMIT 3`, rowMode: 'object', returnValue: 'resultRows' }); console.log(rows); db.close(); } main();
Debug
Known issues
gotchaSharedArrayBuffer requires COOP/COEP headers. Standard HTTP servers like python3 -m http.server do not send them.
fix
Use the included server.js or configure your server to send Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp.
affects: >=0.1.0
breakingsqlite-vec is auto-initialized only when using the official OO1 API. Do not call sqlite3_auto_extension or similar manual init.
fix
Simply use the module as shown in examples; no manual init required.
affects: >=0.1.0
deprecatedThe CommonJS require() pattern is not supported. Package is ESM-only and will not work with require().
fix
Use dynamic import or import statement. Do not use require('sqlite-vec-wasm').
affects: >=0.1.0
gotchaOPFS VFS works only in a Worker thread with the opfs-async-proxy.js file properly served.
fix
Use the worker1.js entry points and serve opfs-async-proxy.js alongside.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: sqlite3InitModule is not a function
Trying to import sqlite-vec-wasm via require() or incorrect path.
fix
Use import sqlite3InitModule from 'sqlite-vec-wasm/dist/sqlite3.mjs'; and ensure your environment supports ES modules.
Uncaught (in promise) Error: SharedArrayBuffer is not available
The page is loaded without required COOP/COEP headers.
fix
Serve your page with the proper headers. Use the included server.js or a server configured as described in the README.
sqlite3.oo1.DB is not a constructor
Trying to use sqlite3 before the module has fully initialized.
fix
Ensure you await sqlite3InitModule() and use the returned module object, not the import default.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
16
Meta
2
OpenAI (training)
1
Resources
sqlite-vec-wasm — npm install sqlite-vec-wasm · libregistry