Exapedia / Tools / JavaScript SQLite libraries JavaScript SQLite libraries Updated Nov 2026
JavaScript SQLite libraries run SQLite, a database engine that keeps a whole database in one file, from Node.js, the browser, or a mobile app. A library either binds to the native engine or runs a WebAssembly build inside the browser. These libraries let desktop apps, mobile apps, and AI agents keep structured local data without a database server.
Popularity better-sqlite3 sql.js libSQL client sqlite3 Expo SQLite SQLite Wasm OP-SQLite sqlite FAQ Popularity better-sqlite3 has the most monthly downloads in this comparison, at 62.1M .
Library Monthly downloads Stars Last release License better-sqlite3 63.3M
7.6K Nov 2026 MIT sql.js 23.9M
13.7K Nov 2026 MIT libSQL client 22.1M
579 Sep 2026 MIT sqlite3 11.7M
6.4K Mar 2026 BSD-3-Clause Expo SQLite 10.6M
53.7K Nov 2026 MIT SQLite Wasm 5.6M
1.1K Oct 2026 Apache-2.0 OP-SQLite 2.9M
1.1K Nov 2026 MIT sqlite 1.0M
935 Nov 2023 MIT Downloads: npm , last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Libraries and code examples Provides synchronous SQLite database and prepared statement APIs for Node.js.
Downloads / mo 63.3M
Stars 7.6K
Last release 13.2.0
License MIT Strengths Reuses prepared statement objects . Prepare a statement once, then bind values for each execution. Groups synchronous work into transactions . Commit successful callbacks and roll back callbacks that throw. Limitations Transaction callbacks cannot await . Keep asynchronous work outside the transaction callback. Large integers need BigInt handling . Use BigInt when stored integers exceed JavaScript number precision. $ npm install better-sqlite3@13.2.0 Copy
const Database = require("better-sqlite3");
const db = new Database(":memory:");
console.log(db.prepare("SELECT 1 AS value").get());
db.close();
better-sqlite3 examples From open-source projects on GitHub get(placeholderValues?: Record<string, unknown>): T['get'] {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { fields, stmt, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
return stmt.get(...params);
}
const row = stmt.raw().get(...params) as unknown[];
if (!row) {
return undefined;
}
if (customResultMapper) {
return customResultMapper([row]) as T['get'];
}
return mapResultRow(fields!, row, joinsNotNullableMap);
}
Show full example Runs SQLite through WebAssembly with in-memory databases and database-file import and export.
Downloads / mo 23.9M
Stars 13.7K
Last release 1.17.0
License MIT Strengths Runs in browsers and Node . Use the same database API across browser and Node hosts. Exports a complete database file . Export the database as a Uint8Array for separate storage. Limitations Changes stay in memory . Export and store database bytes when changes must survive a reload. Prepared statements need explicit cleanup . Free prepared statements after use to release their memory. $ npm install sql.js@1.17.0 Copy
const initSqlJs = require("sql.js");
initSqlJs().then(SQL => {
const db = new SQL.Database();
console.log(db.exec("SELECT 1 AS value"));
db.close();
}).catch(console.error);
sql.js examples From open-source projects on GitHub all(placeholderValues?: Record<string, unknown>): T['all'] {
const stmt = this.client.prepare(this.query.sql);
const { fields, joinsNotNullableMap, logger, query, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = fillPlaceholders(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
stmt.bind(params as BindParams);
const rows: unknown[] = [];
while (stmt.step()) {
rows.push(stmt.getAsObject());
}
stmt.free();
return rows;
}
const rows = this.values(placeholderValues) as unknown[][];
if (customResultMapper) {
return customResultMapper(rows, normalizeFieldValue) as T['all'];
}
return rows.map((row) => mapResultRow(fields!, row.map((v) => normalizeFieldValue(v)), joinsNotNullableMap));
}
Show full example Uses a JavaScript client for local SQLite databases and remote libSQL services.
Downloads / mo 22.1M
Stars 579
Last release 0.18.0
License MIT Strengths Supports local and remote databases . Choose a local database file or a remote libSQL connection. Groups statements into batches . Submit multiple statements together with an explicit transaction mode. Limitations Web clients cannot open files . Use the Node client for local file URLs. Replica writes go to primary . Embedded replicas forward writes to the primary instead of accepting offline writes. $ npm install @libsql/client@0.18.0 Copy
import { createClient } from "@libsql/client";
const client = createClient({ url: ":memory:" });
console.log((await client.execute("SELECT 1 AS value")).rows);
client.close();
libSQL client examples From open-source projects on GitHub override async transaction<T>(
transaction: (db: LibSQLTransaction<TFullSchema, TSchema>) => T | Promise<T>,
_config?: SQLiteTransactionConfig,
): Promise<T> {
// TODO: support transaction behavior
const libsqlTx = await this.client.transaction();
const session = new LibSQLSession<TFullSchema, TSchema>(
this.client,
this.dialect,
this.schema,
this.options,
libsqlTx,
);
const tx = new LibSQLTransaction<TFullSchema, TSchema>('async', this.dialect, session, this.schema);
try {
const result = await transaction(tx);
await libsqlTx.commit();
return result;
} catch (err) {
await libsqlTx.rollback();
throw err;
}
}
Show full example Provides SQLite bindings for Node.js.
Downloads / mo 11.7M
Stars 6.4K
Last release 6.0.1
License BSD-3-Clause $ npm install sqlite3@6.0.1 Copy
const sqlite3 = require("sqlite3");
const db = new sqlite3.Database(":memory:", err => {
if (err) throw err;
db.get("SELECT 1 AS value", [], (err, row) => {
if (err) throw err;
console.log(row);
db.close();
});
});
sqlite3 examples From open-source projects on GitHub _query(connection, obj) {
if (!obj.sql) throw new Error('The query is empty');
const { method } = obj;
let callMethod;
switch (method) {
case 'insert':
case 'update':
callMethod = obj.returning ? 'all' : 'run';
break;
case 'counter':
case 'del':
callMethod = 'run';
break;
default:
callMethod = 'all';
}
return new Promise(function (resolver, rejecter) {
if (!connection || !connection[callMethod]) {
return rejecter(
new Error(`Error calling ${callMethod} on connection.`)
);
}
connection[callMethod](obj.sql, obj.bindings, function (err, response) {
if (err) return rejecter(err);
obj.response = response;
// We need the context here, as it contains
// the "this.lastID" or "this.changes"
obj.context = this;
return resolver(obj);
});
});
}
Show full example Belongs to Expo, a React framework for native apps on Android, iOS, and the web.
Downloads / mo 10.6M
Stars 53.7K
Last release 58.0.18
License MIT $ npx expo install expo-sqlite@58.0.18 Copy
import * as SQLite from "expo-sqlite";
async function firstQuery() {
const db = await SQLite.openDatabaseAsync("demo.db");
console.log(await db.getFirstAsync("SELECT 1 AS value"));
await db.closeAsync();
}
firstQuery().catch(console.error);
Expo SQLite examples From open-source projects on GitHub all(placeholderValues?: Record<string, unknown>): T['all'] {
const { fields, joinsNotNullableMap, query, logger, stmt, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = fillPlaceholders(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
return stmt.executeSync(params as any[]).getAllSync();
}
const rows = this.values(placeholderValues) as unknown[][];
if (customResultMapper) {
return customResultMapper(rows) as T['all'];
}
return rows.map((row) => mapResultRow(fields!, row, joinsNotNullableMap));
}
Show full example Packages SQLite WebAssembly APIs for browser, worker, and in-memory Node usage.
Downloads / mo 5.6M
Stars 1.1K
Last release 3.54.1-build1
License Apache-2.0 Strengths Exposes prepared SQLite statements . Bind values, step through rows, and finalize native statement objects. Uses browser-private file storage . Open an OPFS database from a worker for persistent browser storage. Limitations Node databases stay in memory . Use another binding when Node needs persistent database files. OPFS databases need worker execution . Move the OPFS database workload off the browser’s main thread. $ npm install @sqlite.org/sqlite-wasm@3.54.1-build1 Copy
import sqlite3InitModule from "@sqlite.org/sqlite-wasm";
const sqlite3 = await sqlite3InitModule();
const db = new sqlite3.oo1.DB(":memory:");
console.log(db.selectValue("SELECT 1"));
db.close();
SQLite Wasm examples From open-source projects on GitHub all(...params: unknown[]): unknown[] {
if (this.isFinalized) {
throw new Error("Cannot call all() on finalized statement");
}
this.bindParams(params);
const results: unknown[] = [];
try {
while (this.stmt.step()) {
if (this.isPluckMode) {
// In pluck mode, return only the first column value for each row
const row = this.stmt.get([]);
if (Array.isArray(row) && row.length > 0) {
results.push(row[0]);
}
} else {
results.push(this.isRawMode ? this.stmt.get([]) : this.stmt.get({}));
}
}
return results;
} finally {
this.stmt.reset();
}
}
Show full example Provides a SQLite library for React Native.
Downloads / mo 2.9M
Stars 1.1K
Last release 19.0.5
License MIT $ npm install @op-engineering/op-sqlite@19.0.5 Copy
import { open } from "@op-engineering/op-sqlite";
async function firstQuery() {
const db = open({ name: "demo.sqlite" });
console.log((await db.execute("SELECT 1 AS value")).rows);
db.close();
}
firstQuery().catch(console.error);
OP-SQLite examples From open-source projects on GitHub public async query<T>(sql: string, params?: unknown[]): Promise<T[]> {
if (!this.db) {
throw new Error("Database not initialized");
}
const result = await this.db.execute(sql, params as any[]);
return result.rows as T[];
}
Show full example Wraps sqlite3 with a promise-based client and SQL migrations for Node.js.
Downloads / mo 1.0M
Stars 935
Last release 5.1.1
License MIT $ npm install sqlite@5.1.1 sqlite3@6.0.1 Copy
import sqlite3 from "sqlite3";
import { open } from "sqlite";
const db = await open({ filename: ":memory:", driver: sqlite3.Database });
console.log(await db.get("SELECT 1 AS value"));
await db.close();
sqlite examples From open-source projects on GitHub export async function runSqliteMigrations(db: Database) {
await new Promise((resolve) => {
void migrate(
"sqlite_modify_docs_columns_and_copy_to_config",
async () => {
try {
const pragma = await db.all(
`PRAGMA table_info(${DocsService.sqlitebTableName});`,
);
const hasFaviconCol = pragma.some(
(pragma) => pragma.name === "favicon",
);
if (!hasFaviconCol) {
await db.exec(
`ALTER TABLE ${DocsService.sqlitebTableName} ADD COLUMN favicon BLOB;`,
);
}
const hasBaseUrlCol = pragma.some(
(pragma) => pragma.name === "baseUrl",
);
if (hasBaseUrlCol) {
await db.exec(
`ALTER TABLE ${DocsService.sqlitebTableName} RENAME COLUMN baseUrl TO startUrl;`,
);
}
const needsToUpdateConfig = !hasFaviconCol || hasBaseUrlCol;
if (needsToUpdateConfig) {
const sqliteDocs = await db.all<
Array<Pick<SqliteDocsRow, "title" | "startUrl">>
>(`SELECT title, startUrl FROM ${DocsService.sqlitebTableName}`);
editConfigFile(
(config) => ({
...config,
docs: [...(config.docs || []), ...sqliteDocs],
}),
(config) => ({
...config,
docs: [
...(config.docs || []),
...sqliteDocs.map((doc) => ({
name: doc.title,
startUrl: doc.startUrl,
})),
],
}),
);
}
} finally {
resolve(undefined);
}
},
() => resolve(undefined),
);
});
await new Promise((resolve) => {
void migrate(
"sqlite_delete_docs_with_no_embeddingsProviderId",
async () => {
try {
const pragma = await db.all(
`PRAGMA table_info(${DocsService.sqlitebTableName});`,
);
const hasEmbeddingsProviderColumn = pragma.some(
(pragma) => pragma.name === "embeddingsProviderId",
);
if (!hasEmbeddingsProviderColumn) {
// gotta just delete in this case since old docs will be unusable anyway
await db.exec(`DROP TABLE ${DocsService.sqlitebTableName};`);
}
} finally {
resolve(undefined);
}
},
() => resolve(undefined),
);
});
}
Show full example For coding agents
Found your SQLite library? Help your agent use it. Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.
Claude Code Cursor Codex VS Code Devin Devin Desktop Gemini CLI OpenCode
Run in your terminal
claude plugin install exa@claude-plugins-official Copy Add to ~/.cursor/mcp.json
{
"mcpServers": {
"exa": {
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy Open in your browser, then install the Exa plugin
https://chatgpt.com/plugins/exa Copy Add to .vscode/mcp.json
{
"servers": {
"exa": {
"type": "http",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy In Devin, open Customize, then MCPs, and add a custom HTTP server with this URL
https://mcp.exa.ai/mcp Copy Add to ~/.config/devin/mcp_config.json
{
"mcpServers": {
"exa": {
"serverUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to ~/.gemini/settings.json
{
"mcpServers": {
"exa": {
"httpUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to opencode.json
{
"mcp": {
"exa": {
"type": "remote",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy