sql.js is a pure JavaScript SQLite library compiled with Emscripten, allowing SQL database operations directly in the browser or Node.js without native dependencies. Current stable version is 1.11.0 (as of early 2025), with regular releases. It supports full SQLite syntax, prepared statements, transaction support, and exports database as Uint8Array. Unlike native SQLite bindings (e.g., better-sqlite3), sql.js works entirely in memory and requires loading a .wasm file. It is ideal for client-side web apps, offline tools, and scenarios where native modules cannot be used. The library is MIT licensed and community-maintained.
npm install sql.js-fts5No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows asynchronous initialization, database creation, prepared statements, and query execution.
Provide locateFile in initSqlJs config pointing to the .wasm file, or copy the file from node_modules.
Call db.export() to get Uint8Array, and save it to disk or localStorage.
For file persistence, use native SQLite bindings like better-sqlite3.
Call stmt.free() after use, especially in long-running applications.
Create separate Database instances per worker or use structured cloning.
Wait for initSqlJs to complete and pass the module to an async function.
Provide locateFile option in initSqlJs config pointing to the .wasm file.
Do not reuse closed database; create a new instance if needed.
No dependency data recorded yet.