{"id":46747,"library":"vectorlite","title":"Vectorlite","description":"Vectorlite v0.2.0 is a fast and tunable vector search extension for SQLite, enabling approximate nearest neighbor (ANN) search within SQLite databases. It provides virtual table syntax for creating vector indexes (e.g., with HNSW) and supports storing vectors as JSON or raw float32 buffers. Key differentiators include high performance, tunable parameters, and simple integration with node.js via better-sqlite3 or other SQLite bindings. The release cadence is currently unknown; check GitHub for updates.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/1yefuwang1/vectorlite","tags":["javascript","sqlite3","vector database","vectordb"],"install":[{"cmd":"npm install vectorlite","lang":"bash","label":"npm"},{"cmd":"yarn add vectorlite","lang":"bash","label":"yarn"},{"cmd":"pnpm add vectorlite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import is standard; the library may also support require(). The path is used with db.loadExtension().","wrong":"const vectorlitePath = require('vectorlite').vectorlitePath","symbol":"vectorlitePath","correct":"import { vectorlitePath } from 'vectorlite'"},{"note":"The default export provides vectorlitePath() and possibly other utilities. In CJS, require works fine.","wrong":"const vectorlite = require('vectorlite')","symbol":"vectorlite (default)","correct":"import vectorlite from 'vectorlite'"},{"note":"vector_from_json expects a JSON string; you can pass it directly in SQL as a parameter or literal.","wrong":"SELECT vector_from_json(JSON.stringify(array))","symbol":"vector_from_json","correct":"SELECT vector_from_json(json_string)"}],"quickstart":{"code":"import Database from 'better-sqlite3';\nimport { vectorlitePath } from 'vectorlite';\n\nconst db = new Database(':memory:');\ndb.loadExtension(vectorlitePath());\n\ndb.exec(`CREATE VIRTUAL TABLE vec_test USING vectorlite(vec float32[3], hnsw(max_elements=100));`);\n\ndb.prepare('INSERT INTO vec_test(rowid, vec) VALUES (?, vector_from_json(?))').run(1, JSON.stringify([0.1, 0.2, 0.3]));\ndb.prepare('INSERT INTO vec_test(rowid, vec) VALUES (?, vector_from_json(?))').run(2, JSON.stringify([0.4, 0.5, 0.6]));\n\nconst query = Float32Array.from([0.15, 0.25, 0.35]).buffer;\nconst results = db.prepare('SELECT rowid FROM vec_test WHERE knn_search(vec, knn_param(?, 2))').all(Buffer.from(query));\n\nconsole.log(results);\n// Output: [ { rowid: 1 }, { rowid: 2 } ]","lang":"typescript","description":"Creates an in-memory SQLite database with a vector virtual table using better-sqlite3, inserts two vectors, and performs a k-nearest neighbor search for the top 2 results."},"warnings":[{"fix":"Use JSON.stringify() to serialize arrays before passing to vector_from_json.","message":"When using vector_from_json, you must pass a JSON string, not a JavaScript object.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use Buffer.from(Float32Array.from(array).buffer) to create the correct buffer.","message":"The raw vector buffer must be a Buffer created from a Float32Array's underlying ArrayBuffer. Passing a plain Buffer may produce incorrect results.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Do not parse the output of vectorlite_info() programmatically; use only for debugging.","message":"vectorlite_info() function returns version info but its output format may change between minor versions.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Ensure the first argument to knn_search is the query vector buffer, and knn_param is the second argument.","message":"The knn_param() function's second argument (k) is the number of neighbors. The first argument is the query vector buffer.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Plan vector capacity ahead when defining the virtual table.","message":"The vector index (HNSW) parameters like max_elements must be set at creation time and cannot be changed later.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'ann':18 'approxim':15 'better':59 'better-sqlite3':58 'bind':64 'buffer':44 'cadenc':67 'check':71 'creat':29 'current':69 'databas':22,78 'differenti':46 'e.g':32 'enabl':14 'extens':11 'fast':6 'float32':43 'github':72 'high':48 'hnsw':34 'includ':47 'index':31 'integr':54 'javascript':75 'json':40 'key':45 'nearest':16 'neighbor':17 'node.js':56 'paramet':51 'perform':49 'provid':24 'raw':42 'releas':66 'search':10,19 'simpl':53 'sqlite':13,21,63 'sqlite3':60,76 'store':37 'support':36 'syntax':27 'tabl':26 'tunabl':8,50 'unknown':70 'updat':74 'v0.2.0':3 'vector':9,30,38,77 'vectordb':79 'vectorlit':1,2 'via':57 'virtual':25 'within':20","created_at":"2026-06-07T13:01:26.229883+00:00","updated_at":"2026-06-07T13:01:26.229883+00:00","problems":[{"fix":"Call db.loadExtension(vectorlitePath()) before executing any vectorlite SQL commands.","cause":"Vectorlite extension not loaded into the SQLite connection.","error":"SQLITE_ERROR: no such module: vectorlite"},{"fix":"Use named import: import { vectorlitePath } from 'vectorlite'.","cause":"Importing vectorlite incorrectly (e.g., using default import where vectorlitePath is not exported).","error":"TypeError: vectorlitePath is not a function"},{"fix":"Ensure db.loadExtension(vectorlitePath()) is called first.","cause":"Vectorlite extension not loaded before using vector_from_json function.","error":"SQLITE_ERROR: unknown function: vector_from_json"}],"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/1yefuwang1/vectorlite","github":"https://github.com/1yefuwang1/vectorlite","docs":null,"changelog":null,"pypi":null,"npm":"vectorlite","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}}