This guide compares @photostructure/sqlite with the alternatives to help you choose the right SQLite library for Node.js.
@photostructure/sqlite when you want:node:sqlitenode:sqlite becomes stablebetter-sqlite3 when you want:sqlite3
sqlite3(node-sqlite3) is unmaintained and deprecated as of December 2025. New projects should not use it. Existing users should migrate to one of the alternatives above.
node:sqlite when you're:node:sqlite, Node.js built-in moduleThe official SQLite module included with Node.js 22.5.0+ (experimental)
Pros:
Cons:
Best for: Experimental projects, early adopters, and preparing for the future when it becomes stable.
better-sqlite3The most popular high-performance synchronous SQLite library
Pros:
Cons:
Best for: High-performance applications where you want maximum speed and control over the API.
sqlite3 (deprecated)The original asynchronous SQLite binding for Node.js, unmaintained since December 2025
Status:
Historical context:
Recommendation: Migrate to @photostructure/sqlite, better-sqlite3, or node:sqlite. See migration guide below.
| Feature | @photostructure/sqlite | node:sqlite | better-sqlite3 | sqlite3 |
|---|---|---|---|---|
| API Compatibility | node:sqlite | - | Custom | Custom |
| Min Node.js Version | 20.0.0 | 22.5.0 | 14.0.0 | 10.0.0 |
| Experimental Flag | ✅ Not needed | ❌ needed! | ✅ Not needed | ✅ Not needed |
| Synchronous API | ✅ | ✅ | ✅ | ❌ |
| Asynchronous API | ❌ | ❌ | ❌ | ✅ |
| TypeScript Types | ✅ Built-in | ✅ Built-in | ✅ Via @types | ✅ Via @types |
| Custom Functions | ✅ | ✅ | ✅ | ✅ |
| Aggregate Functions | ✅ | ✅ | ✅ | ❌ |
| Window Functions | ✅ | ✅ | ✅ | ❌ |
| Sessions/Changesets | ✅ | ✅ | ❌ | ❌ |
| Backup API | ✅ | ✅ | ✅ Different API | ✅ |
| Extension Loading | ✅ | ✅ | ✅ | ✅ |
| Worker Threads | ✅ | ✅ | ✅ | ⚠️ Limited |
| FTS5 | ✅ | ✅ | ✅ | ✅ |
| JSON Functions | ✅ | ✅ | ✅ | ✅ |
| R*Tree | ✅ | ✅ | ✅ | ✅ |
| Node-API | ✅ | N/A | ❌ V8-specific | ✅ |
| Disposable Interface | ✅ Native C++ | ✅ Native C++ | ❌ | ❌ |
| Build Size | ~2MB | 0 (built-in) | ~2MB | ~3MB |
All synchronous libraries (@photostructure/sqlite, node:sqlite, better-sqlite3) offer similar performance:
The async sqlite3 library was slower due to:
Note: sqlite3 is deprecated and unmaintained as of December 2025.
Both node:sqlite and @photostructure/sqlite provide SQLTagStore for cached prepared statements via tagged template literals. Node.js implements this in native C++, while we use a TypeScript implementation. Benchmarks show equivalent performance:
| Scenario | @photostructure/sqlite | node:sqlite | Difference |
|---|---|---|---|
| Single query cache hit | 141,000 ops/s | 155,000 ops/s | -9% |
| Multi-pattern workload | 65,000 ops/s | 50,000 ops/s | +31% |
| Write operations | 720 ops/s | 720 ops/s | 0% |
The TypeScript implementation performs equivalently because SQLite execution time dominates over cache lookup overhead. V8's Map is highly optimized for string keys, matching or exceeding native LRU performance for typical workloads.
Run npm run bench:tagstore in the benchmark/ directory to reproduce these results.
node:sqlite to @photostructure/sqlite// Just change the import - everything else stays the same!
// From: import { DatabaseSync } from 'node:sqlite';
import { DatabaseSync } from "@photostructure/sqlite";
better-sqlite3 to @photostructure/sqliteSee our detailed migration guide. Key differences:
enhance() for .transaction() and .pragma() helper methods.name → .location())sqlite3 to @photostructure/sqliteNote: sqlite3 is deprecated and unmaintained as of December 2025. Migration is strongly recommended.
Requires rewriting from async to sync patterns:
// sqlite3 (async)
db.get("SELECT * FROM users WHERE id = ?", [id], (err, row) => {
if (err) handleError(err);
else processUser(row);
});
// @photostructure/sqlite (sync)
try {
const row = db.prepare("SELECT * FROM users WHERE id = ?").get(id);
processUser(row);
} catch (err) {
handleError(err);
}
Choose based on your specific needs:
For new projects targeting Node.js 20+, @photostructure/sqlite offers the best balance of compatibility, performance, and future-proofing.