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
Finance
AI Assistants · Invoicing Finance
Bloomberg-grade financial data and AI-powered analysis through a conversational chat interface you can self-host.
Frappe Books
Invoicing Finance
Offline desktop accounting with double-entry, POS, and custom invoice templates
Glass by Pickle
AI Assistants
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.
Hexabot
AI Development · Automation
Build and run agentic workflows across channels with YAML, tools, and RAG
Karakeep
Bookmarks Archiving
Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.
Kener
Devops · Monitoring
Stunning, self-hosted status pages with real-time uptime monitoring, incident management, and multi-channel notifications in a single Docker container.
ktx
AI Development · Analytics · Data Engineering
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.
Kutt
Analytics · Marketing
Self-hosted URL shortener with custom domains, per-link analytics, and zero build step required.
Logseq
Knowledge Management · Note Taking
A privacy-first, open-source knowledge graph platform combining Markdown, Org-mode, bidirectional linking, and local-first storage for building your second brain.