better-sqlite3
The fastest and simplest SQLite3 library for Node.js, with a synchronous API and full transaction support.
Repository Health
Technical Analysis
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
Termix
Devops
Manage all your servers — SSH terminals, remote desktops, file transfers, and Docker containers — from a single self-hosted browser interface.
VoidAuth
Authentication · Security
Self-hosted SSO with OIDC, LDAP, passkeys, and proxy auth for your entire self-hosted stack
Webiny JS
Blogging · CMS · Ecommerce
Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.
xyops
Automation · Monitoring
A unified, self-hosted platform for job scheduling, visual workflow automation, server monitoring, alerting, and incident response — built for teams who demand full ownership of their operations stack.