|  | 
|  | 1 | +# Node's Built-in SQLite Support | 
|  | 2 | + | 
|  | 3 | +Date: 2025-03-22 | 
|  | 4 | + | 
|  | 5 | +Status: accepted | 
|  | 6 | + | 
|  | 7 | +## Context | 
|  | 8 | + | 
|  | 9 | +The Epic Stack previously used `better-sqlite3` as the SQLite driver for | 
|  | 10 | +Node.js. While `better-sqlite3` is a mature and feature-rich library, Node.js | 
|  | 11 | +has recently added built-in SQLite support through the `node:sqlite3` module. | 
|  | 12 | +This built-in support provides a simpler, more maintainable solution that | 
|  | 13 | +doesn't require additional dependencies. | 
|  | 14 | + | 
|  | 15 | +The built-in SQLite support in Node.js is based on the same underlying SQLite | 
|  | 16 | +engine, ensuring compatibility with our existing database schema and queries. It | 
|  | 17 | +also provides a Promise-based API that aligns well with modern JavaScript | 
|  | 18 | +practices. | 
|  | 19 | + | 
|  | 20 | +## Decision | 
|  | 21 | + | 
|  | 22 | +We will switch from `better-sqlite3` to Node's built-in SQLite support | 
|  | 23 | +(`node:sqlite3`) for the following reasons: | 
|  | 24 | + | 
|  | 25 | +1. Reduced dependencies - one less package to maintain and update | 
|  | 26 | +2. Native integration with Node.js - better long-term support and compatibility | 
|  | 27 | +3. Simpler setup - no need to handle native module compilation | 
|  | 28 | +4. Official Node.js support - better reliability and future-proofing | 
|  | 29 | + | 
|  | 30 | +## Consequences | 
|  | 31 | + | 
|  | 32 | +This change will require: | 
|  | 33 | + | 
|  | 34 | +1. Updating database connection code to use the new API | 
|  | 35 | +2. Removing `better-sqlite3` from package.json and lockfile | 
|  | 36 | + | 
|  | 37 | +The migration should be relatively straightforward since both libraries use the | 
|  | 38 | +same underlying SQLite engine. The main changes will be in the API usage | 
|  | 39 | +patterns rather than the database functionality itself. | 
|  | 40 | + | 
|  | 41 | +This change aligns with our goal of simplifying the stack while maintaining | 
|  | 42 | +robust functionality. The built-in SQLite support provides all the features we | 
|  | 43 | +need without the overhead of an additional dependency. | 
0 commit comments