Registry / database / sqlite-wasm-vec

sqlite-wasm-vec

JSON →
library0.1.11jsnpmunverified

SQLite compiled to WebAssembly with the sqlite-vec extension for vector similarity search. Version 0.1.11 bundles SQLite 3.51.0 and sqlite-vec v0.1.7-alpha.2 in a ~1.5MB WASM binary. Provides full SQLite API with vector operations (k-NN search, distance functions) directly in browsers and Node.js. Supports float, int8, and bit vector types via virtual tables. Includes OPFS for persistent storage in browsers and first-class TypeScript types. Fork of @sqlite.org/sqlite-wasm with all original features intact.

npm install sqlite-wasm-vec
INSTALL
IMPORT
SIG · SQLITE-WASM-VEC
S
sqlite-wasm-vec
databasejavascriptv0.1.11
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-wasm-vec'
import { sqlite3InitModule } from 'sqlite-wasm-vec'
Default export only. Named import will cause undefined.
oo1.DB
const db = new sqlite3.oo1.DB(':memory:')
import { DB } from 'sqlite-wasm-vec'
DB is a property of the sqlite3 object returned by init; not directly importable.
sqlite3InitModule (CommonJS)
const sqlite3InitModule = require('sqlite-wasm-vec').default
const sqlite3InitModule = require('sqlite-wasm-vec')
CJS users must use .default; ES module is the primary format.

Initializes SQLite with vector support, creates a virtual table, inserts a vector, and performs a k-NN similarity search.

import sqlite3InitModule from 'sqlite-wasm-vec'; const sqlite3 = await sqlite3InitModule(); const db = new sqlite3.oo1.DB(':memory:'); // Create virtual table for vectors db.exec(`CREATE VIRTUAL TABLE vec_items USING vec0(embedding float[384])`); // Insert a vector const embedding = new Float32Array(384).fill(0.1); db.exec({ sql: 'INSERT INTO vec_items(rowid, embedding) VALUES (?, ?)', bind: [1, embedding.buffer] }); // Search for nearest neighbors const query = new Float32Array(384).fill(0.2); const results = db.selectArrays( 'SELECT rowid, distance FROM vec_items WHERE embedding MATCH ? ORDER BY distance LIMIT 5', query.buffer ); console.log('Results:', results);
Debug
Known issues
gotchaNode.js support is limited to in-memory databases. Persistent storage is not available in Node.js.
fix
Use ':memory:' for Node.js; for persistence, run in browser with OPFS enabled.
affects: >=0.1.0
gotchaVector buffers must be passed as ArrayBuffer (typedArray.buffer) to binding functions or exec bind. Passing Float32Array directly will fail.
fix
Use `embedding.buffer` when binding vector data to SQL statements.
affects: >=0.1.0
deprecatedThe default export is the initialization function alone. There is no separate export for the WASM URL or binary.
fix
Access the WASM resource internally; no public export provided.
affects: >=0.1.0
gotchasqlite-vec functions (vec_version, vec_distance_cosine, etc.) only work after initialization and on tables created with `vec0` virtual table syntax.
fix
Ensure you create virtual tables using `CREATE VIRTUAL TABLE ... USING vec0(...)` before calling vector operations.
affects: >=0.1.0
Errors
Common errors & fixes
Error: vec0 virtual table not found
Forgot to include sqlite-vec extension or created regular table instead of virtual table.
fix
Use `CREATE VIRTUAL TABLE ... USING vec0(...)` syntax.
TypeError: Cannot read properties of undefined (reading 'oo1')
Importing named export 'sqlite3' instead of default export from 'sqlite-wasm-vec'.
fix
Use `import sqlite3InitModule from 'sqlite-wasm-vec'` and then `const sqlite3 = await sqlite3InitModule()`.
Error: The argument to bind must be an ArrayBuffer
Passing Float32Array directly instead of its buffer property to SQL bind parameters.
fix
Pass `embedding.buffer` instead of `embedding`.
Upgrade
Version history
0.1.11latest on npm
Audit
Dependencies

No dependency data recorded yet.

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