# JavaScript SQLite libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [better-sqlite3](#better-sqlite) | 63.3M | 7.6K | Nov 2026 | MIT |
| [sql.js](#sql-js) | 23.9M | 13.7K | Nov 2026 | MIT |
| [libSQL client](#libsql-client) | 22.1M | 579 | Sep 2026 | MIT |
| [sqlite3](#sqlitethree) | 11.7M | 6.4K | Mar 2026 | BSD-3-Clause |
| [Expo SQLite](#expo-sqlite) | 10.6M | 53.7K | Nov 2026 | MIT |
| [SQLite Wasm](#sqlite-wasm) | 5.6M | 1.1K | Oct 2026 | Apache-2.0 |
| [OP-SQLite](#op-engineering-op-sqlite) | 2.9M | 1.1K | Nov 2026 | MIT |
| [sqlite](#sqlite) | 1.0M | 935 | Nov 2023 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[better-sqlite3](#better-sqlite) has the most monthly downloads in this comparison, at 62.1M.

## Capabilities

| Library | Browser execution | Automatic file persistence |
| --- | --- | --- |
| [better-sqlite3](#better-sqlite) | No | Yes |
| [sql.js](#sql-js) | Yes | No |
| [libSQL client](#libsql-client) | Yes | Yes |
| [sqlite3](#sqlitethree) | No | Yes |
| [Expo SQLite](#expo-sqlite) | Yes | Yes |
| [SQLite Wasm](#sqlite-wasm) | Yes | Yes |
| [OP-SQLite](#op-engineering-op-sqlite) | Yes | Yes |
| [sqlite](#sqlite) | No | Yes |

## Libraries

### better-sqlite3

[GitHub](https://github.com/WiseLibs/better-sqlite3) · [npm](https://www.npmjs.com/package/better-sqlite3) · [Docs](https://raw.githubusercontent.com/WiseLibs/better-sqlite3/master/docs/api.md)

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
- Capabilities: [From the better-sqlite3 docs](https://raw.githubusercontent.com/WiseLibs/better-sqlite3/master/docs/api.md)

**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.

**Watch out for**

- **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.

```sh
npm install better-sqlite3@13.2.0
```

**drizzle-team/drizzle-orm** (36.3K stars)

[drizzle-team/drizzle-orm](https://github.com/drizzle-team/drizzle-orm) 

```typescript
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);
	}

```

[drizzle-orm/src/better-sqlite3/session.ts](https://github.com/drizzle-team/drizzle-orm/blob/3bcb6a27ec1f4f1602aeeb0af2f5aec61010d72d/drizzle-orm/src/better-sqlite3/session.ts#L150) · [More projects using better-sqlite3 →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20better-sqlite3%20for%20native%20statements%2C%20bound%20rows%2C%20explicit%20cleanup%20and%20database%20transactions&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
const Database = require("better-sqlite3");
const db = new Database(":memory:");
console.log(db.prepare("SELECT 1 AS value").get());
db.close();

```

From [api.md](https://raw.githubusercontent.com/WiseLibs/better-sqlite3/master/docs/api.md)

### sql.js

[GitHub](https://github.com/sql-js/sql.js) · [npm](https://www.npmjs.com/package/sql.js) · [Docs](https://raw.githubusercontent.com/sql-js/sql.js/master/README.md)

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
- Capabilities: [From the sql.js docs](https://raw.githubusercontent.com/sql-js/sql.js/master/README.md)

**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.

**Watch out for**

- **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.

```sh
npm install sql.js@1.17.0
```

**drizzle-team/drizzle-orm** (36.3K stars)

[drizzle-team/drizzle-orm](https://github.com/drizzle-team/drizzle-orm) 

```typescript
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));
	}

```

[drizzle-orm/src/sql-js/session.ts](https://github.com/drizzle-team/drizzle-orm/blob/3bcb6a27ec1f4f1602aeeb0af2f5aec61010d72d/drizzle-orm/src/sql-js/session.ts#L118) · [More projects using sql.js →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20sql.js%20for%20native%20statements%2C%20bound%20rows%2C%20explicit%20cleanup%20and%20database%20transactions&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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);

```

From [README.md](https://raw.githubusercontent.com/sql-js/sql.js/master/README.md)

### libSQL client

[GitHub](https://github.com/tursodatabase/libsql-client-ts) · [npm](https://www.npmjs.com/package/@libsql/client) · [Docs](https://docs.turso.tech/sdk/ts/reference)

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
- Capabilities: [From the libSQL client docs](https://docs.turso.tech/sdk/ts/reference)

**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.

**Watch out for**

- **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.

```sh
npm install @libsql/client@0.18.0
```

**drizzle-team/drizzle-orm** (36.3K stars)

[drizzle-team/drizzle-orm](https://github.com/drizzle-team/drizzle-orm) 

```typescript
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;
		}
	}

```

[drizzle-orm/src/libsql/session.ts](https://github.com/drizzle-team/drizzle-orm/blob/3bcb6a27ec1f4f1602aeeb0af2f5aec61010d72d/drizzle-orm/src/libsql/session.ts#L107) · [More projects using libSQL client →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20%40libsql/client%20for%20native%20statements%2C%20bound%20rows%2C%20explicit%20cleanup%20and%20database%20transactions&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { createClient } from "@libsql/client";
const client = createClient({ url: ":memory:" });
console.log((await client.execute("SELECT 1 AS value")).rows);
client.close();

```

From [index.mjs](https://docs.turso.tech/sdk/ts/reference)

### sqlite3

[GitHub](https://github.com/TryGhost/node-sqlite3) · [npm](https://www.npmjs.com/package/sqlite3) · [Docs](https://github.com/TryGhost/node-sqlite3/wiki/API)

Provides SQLite bindings for Node.js.

- Downloads / mo: 11.7M
- Stars: 6.4K
- Last release: 6.0.1
- License: BSD-3-Clause
- Capabilities: [From the sqlite3 docs](https://github.com/TryGhost/node-sqlite3/wiki/API)

```sh
npm install sqlite3@6.0.1
```

**knex/knex** (20.3K stars)

[knex/knex](https://github.com/knex/knex) 

```javascript
_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);
      });
    });
  }

```

[lib/dialects/sqlite3/index.js](https://github.com/knex/knex/blob/e25d54bcb707714a17f5a5744eba5c4246bb4d1d/lib/dialects/sqlite3/index.js#L134) · [More projects using sqlite3 →](https://dashboard.exa.ai/playground/search?q=sqlite3%20GitHub%20projects)

**Quickstart**

```javascript
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();
  });
});

```

From [API.md](https://github.com/TryGhost/node-sqlite3/wiki/API)

### Expo SQLite

[GitHub](https://github.com/expo/expo) · [npm](https://www.npmjs.com/package/expo-sqlite) · [Docs](https://docs.expo.dev/versions/latest/sdk/sqlite/)

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
- Capabilities: [From the Expo SQLite docs](https://docs.expo.dev/versions/latest/sdk/sqlite/)

```sh
npx expo install expo-sqlite@58.0.18
```

**drizzle-team/drizzle-orm** (36.3K stars)

[drizzle-team/drizzle-orm](https://github.com/drizzle-team/drizzle-orm) 

```javascript
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));
	}

```

[drizzle-orm/src/expo-sqlite/session.ts](https://github.com/drizzle-team/drizzle-orm/blob/3bcb6a27ec1f4f1602aeeb0af2f5aec61010d72d/drizzle-orm/src/expo-sqlite/session.ts#L127) · [More projects using Expo SQLite →](https://dashboard.exa.ai/playground/search?q=expo-sqlite%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [sqlite.mdx](https://docs.expo.dev/versions/latest/sdk/sqlite/)

### SQLite Wasm

[GitHub](https://github.com/sqlite/sqlite-wasm) · [npm](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm) · [Docs](https://sqlite.org/wasm/doc/trunk/api-oo1.md)

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
- Capabilities: [From the SQLite Wasm docs](https://sqlite.org/wasm/doc/trunk/api-oo1.md)

**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.

**Watch out for**

- **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.

```sh
npm install @sqlite.org/sqlite-wasm@3.54.1-build1
```

**TriliumNext/Trilium** (39.0K stars)

[TriliumNext/Trilium](https://github.com/TriliumNext/Trilium) 

```typescript
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();
        }
    }

```

[apps/standalone/src/lightweight/sql_provider.ts](https://github.com/TriliumNext/Trilium/blob/3c60eac13f66161492334efefa2613923ebe541f/apps/standalone/src/lightweight/sql_provider.ts#L71) · [More projects using SQLite Wasm →](https://dashboard.exa.ai/playground/search?q=TypeScript%20projects%20using%20%40sqlite.org/sqlite-wasm%20for%20native%20statements%2C%20bound%20rows%2C%20explicit%20cleanup%20and%20database%20transactions&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
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();

```

From [main.ts](https://sqlite.org/wasm/doc/trunk/api-oo1.md)

### OP-SQLite

[GitHub](https://github.com/OP-Engineering/op-sqlite) · [npm](https://www.npmjs.com/package/@op-engineering/op-sqlite) · [Docs](https://op-engineering.github.io/op-sqlite/docs/api/)

Provides a SQLite library for React Native.

- Downloads / mo: 2.9M
- Stars: 1.1K
- Last release: 19.0.5
- License: MIT
- Capabilities: [From the OP-SQLite docs](https://op-engineering.github.io/op-sqlite/docs/api/)

```sh
npm install @op-engineering/op-sqlite@19.0.5
```

**garden-co/classic-jazz** (2.5K stars)

[garden-co/classic-jazz](https://github.com/garden-co/classic-jazz) 

```javascript
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[];
  }

```

[packages/jazz-tools/src/react-native/storage/op-sqlite-adapter.ts](https://github.com/garden-co/classic-jazz/blob/e51832fd1f495a771d89f9c26aa9f6a62c3e0690/packages/jazz-tools/src/react-native/storage/op-sqlite-adapter.ts#L68) · [More projects using OP-SQLite →](https://dashboard.exa.ai/playground/search?q=%40op-engineering/op-sqlite%20GitHub%20projects)

**Quickstart**

```javascript
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);

```

From [README.md](https://op-engineering.github.io/op-sqlite/docs/api/)

### sqlite

[GitHub](https://github.com/kriasoft/node-sqlite) · [npm](https://www.npmjs.com/package/sqlite) · [Docs](https://raw.githubusercontent.com/kriasoft/node-sqlite/master/README.md)

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
- Capabilities: [From the sqlite docs](https://raw.githubusercontent.com/kriasoft/node-sqlite/master/README.md)

```sh
npm install sqlite@5.1.1 sqlite3@6.0.1
```

**continuedev/continue** (36.5K stars)

[continuedev/continue](https://github.com/continuedev/continue) 

```javascript
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),
    );
  });
}

```

[core/indexing/docs/migrations.ts](https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/indexing/docs/migrations.ts#L28) · [More projects using sqlite →](https://dashboard.exa.ai/playground/search?q=sqlite%20GitHub%20projects)

**Quickstart**

```javascript
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();

```

From [README.md](https://raw.githubusercontent.com/kriasoft/node-sqlite/master/README.md)

## FAQ

### Which JavaScript SQLite library should I use?

[better-sqlite3](#better-sqlite) suits Node.js apps that want fast synchronous queries on a local file. [sql.js](#sql-js) and [SQLite Wasm](#sqlite-wasm) suit browser apps. [Expo SQLite](#expo-sqlite) and [OP-SQLite](#op-engineering-op-sqlite) suit React Native apps.

### What is libSQL?

libSQL is a fork of SQLite that also runs as a remote database service. The [libSQL client](#libsql-client) connects to local libSQL files and to remote libSQL services from one API.

### better-sqlite3 vs sqlite3: which should I use?

[better-sqlite3](#better-sqlite) runs queries synchronously with reusable prepared statements. [sqlite3](#sqlitethree) uses callbacks for its run, get, and all operations.

### How do I use SQLite in the browser?

[sql.js](#sql-js) runs SQLite through WebAssembly with an in-memory database that the app imports and exports as bytes. [SQLite Wasm](#sqlite-wasm) is the official WebAssembly build, with persistent storage in a worker.

### What is Expo SQLite?

[Expo SQLite](#expo-sqlite) is the Expo module for SQLite in React Native apps. It offers asynchronous and synchronous query APIs, with data that persists on the device.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript SQLite libraries better-sqlite3 sql.js libsql official sqlite-wasm code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
