better-sqlite3

Fast, synchronous SQLite3 database driver for Node.js. better-sqlite3 is intentionally synchronous (no callbacks, no promises) — it uses SQLite's synchronous C API directly for maximum performance. Significantly faster than node-sqlite3 for most operations. Used for local agent databases, testing, embedded apps, and CLI tools where SQLite's zero-config setup is ideal.

Evaluated Mar 06, 2026 (0d ago) v9.x
Homepage ↗ Repo ↗ Developer Tools sqlite database node synchronous embedded fast native-addon local-database
⚙ Agent Friendliness
69
/ 100
Can an agent use this?
🔒 Security
84
/ 100
Is it safe for agents?
⚡ Reliability
92
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
90
Error Messages
88
Auth Simplicity
92
Rate Limits
100

🔒 Security

TLS Enforcement
100
Auth Strength
80
Scope Granularity
75
Dep. Hygiene
88
Secret Handling
78

Local file database — protect file permissions. SQL injection impossible with prepared statements (db.prepare()); never use string interpolation in SQL. Database file at rest is unencrypted without SQLite SEE.

⚡ Reliability

Uptime/SLA
100
Version Stability
90
Breaking Changes
88
Error Recovery
90
AF Security Reliability

Best When

Local agent tools, CLI apps, test databases, or embedded applications where SQLite's simplicity and better-sqlite3's speed are ideal.

Avoid When

High-concurrency server production databases — use PostgreSQL or MySQL for multi-user server applications.

Use Cases

  • Store agent state, configuration, and results in a local SQLite database without network infrastructure using better-sqlite3's zero-config setup
  • Run fast local database queries in agent CLI tools where synchronous database access simplifies code and avoids async complexity
  • Use as test database for agent applications — SQLite in-memory (:memory:) databases provide fast, isolated test environments
  • Build agent applications that ship with an embedded database — no separate database server required, database is a single file
  • Cache agent API responses and computed results locally using SQLite full-text search for fast semantic retrieval

Not For

  • High-concurrency server applications — SQLite WAL mode handles some concurrency but isn't designed for high write throughput; use PostgreSQL for production servers
  • Multi-process concurrent write access — SQLite has file-level locking; multiple Node.js processes writing simultaneously cause lock contention
  • Async-heavy Node.js applications — better-sqlite3's synchronous API blocks the event loop; use async SQLite drivers for highly concurrent servers

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth for local SQLite files. SQLite Encryption Extension (SEE) available commercially for encrypted databases. File system permissions control database access.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

better-sqlite3 is open source and free. SQLite itself is public domain.

Agent Metadata

Pagination
cursor
Idempotent
Full
Retry Guidance
Not documented

Known Gotchas

  • Synchronous API blocks the Node.js event loop — long-running queries (large table scans) freeze all other I/O; run in a worker thread for heavy queries in servers
  • Native C++ addon requires build tools at install time — CI pipelines need python, make, and gcc; or use prebuilt binaries via electron-rebuild for Electron apps
  • SQLite WAL mode is not enabled by default — enable with PRAGMA journal_mode=WAL for better concurrent read performance; required for multiple simultaneous readers
  • Integer primary keys overflow at 2^63 in SQLite — large agent event tables with billions of rows should use ROWID explicitly or TEXT UUIDs as primary keys
  • SQLite doesn't enforce foreign key constraints by default — enable with PRAGMA foreign_keys=ON at connection time; forgetting this causes silent referential integrity issues
  • better-sqlite3 connection is not thread-safe — don't share a Database instance across worker threads; create one connection per thread

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for better-sqlite3.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5616
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered