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 39 apps in this directory
Actual
Invoicing Finance
Local-first personal finance with envelope budgeting, end-to-end encryption, and multi-device sync — no subscription required.
Agents Observe
Developer Tools
A real-time, fully local observability dashboard for Claude Code and Codex agent sessions — filtering, search, session replay, and token/cost breakdowns via an auto-starting MCP server.
AionUi
AI Agents · Productivity
Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.
Bun
Developer Tools
An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.
Cherry Studio
AI Assistants
All-in-one AI desktop client with 300+ assistants and multi-model support
Cline
AI Code Assistants
An open-source AI coding agent that lives in your editor and terminal — reads and edits your codebase, runs commands, browses the web, and requires human approval for every action by default.
Colanode
Knowledge Management · Team Chat · Collaboration
Local-first, self-hosted workspace that combines real-time chat, Notion-style pages, and structured databases — all synced via CRDTs so you work offline without losing a keystroke.
Dyad
AI Development · Productivity · AI Code Assistants
Build AI-powered apps locally with your own keys, your own models, and zero cloud lock-in.
Finance
AI Assistants · Invoicing Finance
Bloomberg-grade financial data and AI-powered analysis through a conversational chat interface you can self-host.