I run eleven small AI apps on a free Vercel plan. No managed Postgres, no Redis, no monthly bill. When you refuse to pay for a database, you end up asking a strange question: can SQLite just live inside the function?
The answer is yes. It also comes with a footgun that took me a while to see clearly, and I think most "SQLite on serverless" posts skip it.
The setup
The library is sql.js — SQLite compiled to WebAssembly. No native bindings, no build step, no binary that breaks on a different OS. It loads a .wasm file and gives you a database object in memory.
const initSqlJs = require ( 'sql.js' ) ;
const SQL = await initSqlJs ( { locateFile : ( ) => path . join ( __dirname , 'node_modules/sql.js/dist/sql-wasm.wasm' ) , } ) ;
const db = new SQL . Database ( ) ; db . run ( 'CREATE TABLE leads (id INTEGER PRIMARY KEY, email TEXT)' ) ;
Enter fullscreen mode
Exit fullscreen mode
From there it behaves like SQLite.…