better-sqlite3

The fastest and simplest SQLite3 library for Node.js, with a synchronous API and full transaction support.

Library
npm
v13.0.3
7,525 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
70 /100 Good
Development Activity 44
Maintenance 72
Community 64
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
90 /100 Excellent
Architecture 90
Code Quality 90
Innovation 95
Learning Curve 85

better-sqlite3 is a high-performance SQLite3 binding for Node.js that exposes a deliberately synchronous API. Instead of forcing callbacks or promises onto operations that are CPU-bound and serialized by SQLite anyway, it lets you prepare statements and read rows inline, which is both simpler to reason about and measurably faster than asynchronous alternatives.

Built on a native C++ addon that embeds SQLite directly, it delivers full transaction support, user-defined functions, aggregates, virtual tables, 64-bit integers, and worker-thread support. Prebuilt binaries ship for supported Node.js LTS versions, so most projects can install and query a database in a couple of lines.

What You Get

  • A synchronous prepared-statement API with get(), all(), iterate(), and run() for reading and writing rows without callbacks or promises
  • Full transaction support via db.transaction(), including nested savepoints and automatic rollback on error
  • Extensibility hooks for user-defined functions, aggregates, virtual tables, and loadable extensions
  • First-class 64-bit integer handling, opt-in per statement or database-wide
  • Prebuilt native binaries for supported Node.js LTS versions, plus worker-thread support for large or slow queries

Common Use Cases

  • Embedding a fast local database in desktop, CLI, or Electron applications
  • Powering server-side caches, queues, or read-heavy stores where an embedded database beats a network round-trip
  • Running data-import, ETL, or migration scripts that need tight synchronous control over transactions
  • Backing test suites and prototypes with an in-memory SQLite database

Under The Hood

Architecture - better-sqlite3 is a thin, well-factored JavaScript layer (lib/database.js and lib/methods/*.js) sitting on top of a native C++ addon (src/objects/database.cpp, statement.cpp, backup.cpp) that embeds SQLite from deps/. The Database constructor validates options, lazily loads the compiled better_sqlite3.node binding via the bindings package, and wires prototype methods (prepare, transaction, pragma, backup, function, aggregate, table) onto each instance; a hidden cppdb symbol holds the native handle so calls like prepare().get() drop straight into C++ for execution.

Tech Stack - The library targets Node.js 20 through 26 and ships as JavaScript (~68%) over C++ (~32%). Runtime dependencies are minimal: bindings for locating the addon and prebuild-install to fetch prebuilt binaries, falling back to node-gyp rebuild through binding.gyp when none match. Testing and benchmarking use mocha, chai, nodemark, and the competing sqlite/sqlite3 packages for comparison.

Code Quality - The repo carries a substantial mocha suite of roughly thirty numbered test files covering database open/close, pragmas, statement run/get/all/iterate, transactions, and error cases. Input validation is thorough and defensive: the constructor throws precise TypeError/RangeError messages for misspelled or removed options, and errors surface through a dedicated SqliteError class. Naming is consistent and the small util module keeps shared symbols and option parsing centralized.

API Design - The public surface is deliberately minimal and ergonomic: new Database(path) then prepare(sql) returning a statement with get/all/iterate/run keeps boilerplate near zero, and the synchronous model removes the callback nesting other bindings require. Extensive docs (api.md plus dedicated performance, integer, threads, and troubleshooting guides) and clear README examples make the learning curve gentle for anyone who already knows SQL.

Used by 40 apps in this directory

TypeScript
96%

Finance

AI Assistants · Invoicing Finance

906

Bloomberg-grade financial data and AI-powered analysis through a conversational chat interface you can self-host.

View details
51
Repo Health
62
Technical
69
Dependency
Built with
TypeScript 96%
Updated 1 months ago
TypeScript
58%
AGPL 3.0

Frappe Books

Invoicing Finance

5,003

Offline desktop accounting with double-entry, POS, and custom invoice templates

View details
88
Repo Health
77
Technical
72
Dependency
Built with
TypeScript 58%
Vue 39%
Updated 4 weeks ago
JavaScript
88%
GPL 3.0

Glass by Pickle

AI Assistants

7,604

A privacy-first desktop AI assistant that sees your screen, hears your meetings, and turns live context into structured summaries—without sending a single byte to the cloud.

View details
43
Repo Health
76
Technical
68
Dependency
Built with
JavaScript 88%
TypeScript 12%
Updated 1 years ago
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,160

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
76
Repo Health
76
Technical
65
Dependency
Built with
TypeScript 98%
Updated 1 months ago
TypeScript
98%
AGPL 3.0

Karakeep

Bookmarks Archiving

29,926

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
52%

Kener

Devops · Monitoring

5,216

Stunning, self-hosted status pages with real-time uptime monitoring, incident management, and multi-channel notifications in a single Docker container.

View details
87
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 52%
Svelte 45%
Updated 1 weeks ago
TypeScript
84%
Apache 2.0

ktx

AI Development · Analytics · Data Engineering

1,623

ktx builds a self-improving context layer over your data warehouse so AI agents like Claude Code and Codex query it with approved metric definitions instead of reinventing SQL logic from scratch.

View details
52
Repo Health
85
Technical
71
Dependency
Built with
TypeScript 84%
Updated 1 weeks ago
JavaScript
46%
MIT

Kutt

Analytics · Marketing

11,166

Self-hosted URL shortener with custom domains, per-link analytics, and zero build step required.

View details
68
Repo Health
62
Technical
71
Dependency
Built with
JavaScript 46%
Handlebars 24%
HTML 16%
Updated 1 weeks ago
Clojure
71%
AGPL 3.0

Logseq

Knowledge Management · Note Taking

45,349

A privacy-first, open-source knowledge graph platform combining Markdown, Org-mode, bidirectional linking, and local-first storage for building your second brain.

View details
92
Repo Health
82
Technical
65
Dependency
Built with
Clojure 71%
OCaml 12%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers