
@sqlite.org/sqlite-wasm
SQLite Wasm conveniently wrapped as an ES Module.
About
SQLite Wasm conveniently wrapped as an ES Module.
Live mirror of the GitHub README. Updated whenever the repo's default branch changes.
SQLite Wasm
SQLite Wasm conveniently wrapped as an ES Module.
Installation
npm install @sqlite.org/sqlite-wasm
Bug reports
[!Warning]
This project wraps the code of SQLite Wasm with no changes, apart from added TypeScript types. Please do not file issues or feature requests regarding the underlying SQLite Wasm code here. Instead, please follow the SQLite bug filing instructions. Filing TypeScript type related issues and feature requests is fine.
Node.js support
[!Warning]
Node.js is currently only supported for in-memory databases without persistence.
Usage
There are two ways to use SQLite Wasm:
Only the worker versions allow you to use the origin private file system (OPFS) storage back-end.
In a worker (with OPFS if available):
[!Warning]
For this to work, you need to set the following headers on your server:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
// In `main.js`.
const worker = new Worker('worker.js', { type: 'module' });
// In `worker.js`.
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
const start = (sqlite3) => {
console.log('Running SQLite3 version', sqlite3.version.libVersion);
const db =
'opfs' in sqlite3
? new sqlite3.oo1.OpfsDb('/mydb.sqlite3')
: new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');
console.log(
'opfs' in sqlite3
? `OPFS is available, created persisted database at ${db.filename}`
: `OPFS is not available, created transient database ${db.filename}`,
);
// Your SQLite code here.
};
const initializeSQLite = async () => {
try {
console.log('Loading and initializing SQLite3 module...');
const sqlite3 = await sqlite3InitModule();
console.log('Done initializing. Running demo...');
start(sqlite3);
} catch (err) {
console.error('Initialization error:', err.name, err.message);
}
};
initializeSQLite();
The db object above implements the
Object-Oriented API #1.
In the main thread (without OPFS):
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';
const start = (sqlite3) => {
log('Running SQLite3 version', sqlite3.version.libVersion);
const db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');
// Your SQLite code here.
};
const initializeSQLite = async () => {
try {
console.log('Loading and initializing SQLite3 module...');
const sqlite3 = await sqlite3InitModule();
console.log('Done initializing. Running demo...');
start(sqlite3);
} catch (err) {
console.error('Initialization error:', err.name, err.message);
}
};
initializeSQLite();
The db object above implements the
Object-Oriented API #1.
Usage with vite
If you are using vite, you need to add the following config option in
vite.config.js:
import { defineConfig } from 'vite';
export default defineConfig({
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
optimizeDeps: {
exclude: ['@sqlite.org/sqlite-wasm'],
},
});
Check out a sample project that shows this in action.
Demo
See the demo folder for examples of how to use this in the main thread and in a worker. (Note that the worker variant requires special HTTP headers, so it can't be hosted on GitHub Pages.) An example that shows how to use this with vite is available on StackBlitz.
Projects using this package
See the list of npm dependents for this package.
Deploying a new version
(These steps can only be executed by maintainers.)
-
Manually trigger the GitHub Actions workflow. By default, it uses the latest SQLite tag. This pull request will contain the latest
sqlite3.wasmand related bindings. -
Once the above pull request is validated and merged, update the version number in
package.json, reflecting the current SQLite version number and add a build identifier suffix like-build1. The complete version number should read something like3.41.2-build1.
Building the SQLite Wasm locally
-
Build the Docker image:
docker build -t sqlite-wasm-builder:env . -
Run the build:
Unix (Linux/macOS):
docker run --rm \ -e SQLITE_REF="master" \ -v "$(pwd)/out":/out \ -v "$(pwd)/src/bin":/src/bin \ sqlite-wasm-builder:env buildWindows (PowerShell):
docker run --rm ` -e SQLITE_REF="master" ` -v "${PWD}/out:/out" ` -v "${PWD}/src/bin:/src/bin" ` sqlite-wasm-builder:env buildWindows (Command Prompt):
docker run --rm ^ -e SQLITE_REF="master" ^ -v "%cd%/out:/out" ^ -v "%cd%/src/bin:/src/bin" ^ sqlite-wasm-builder:env build
Running tests
The test suite consists of Node.js tests and browser-based tests (using Vitest Browser Mode). Tests aim to sanity-check the exported scripts. We test for correct exports and very basic functionality.
-
Install dependencies:
npm install -
Install Playwright browsers (required for browser tests):
npx playwright install chromium --with-deps --no-shell -
Run all tests:
npm test
Deprecations
The Worker1 and Promiser1 APIs are, as of 2026-04-15, deprecated. They will not be removed, but they also will not be extended further. It is their author's considered opinion that they are too fragile, too imperformant, and too limited for any non-toy software, and their use is actively discouraged. The "correct" way to use this library is documented in Usage section above.
License
Apache 2.0.
Acknowledgements
This project is based on SQLite Wasm, which it conveniently wraps as an
ES Module and publishes to npm as
@sqlite.org/sqlite-wasm.
Quick facts
npm install @sqlite.org/sqlite-wasmHow Sourcemap Explorer detects @sqlite.org/sqlite-wasm
We catch @sqlite.org/sqlite-wasm from two complementary signals: bundled source paths and the embedded package.json. Modern bundlers (webpack, Vite, esbuild, Rollup, Turbopack) preserve the original node_modules/@sqlite.org/sqlite-wasm/ paths inside the JavaScript sourcemap's sources[] array — that's the canonical signal. When the matching package.json is also captured in sourcesContent[], we read the exact version field — patch number included. No regex guessing, no version inference.
- 1
Confirm the site exposes sourcemaps
In DevTools Network, check the response headers of any application script for `SourceMap` or `X-SourceMap`. Failing that, fetch the script's last 4 KB and look for a `//# sourceMappingURL=` comment.
- 2
Find the package in the bundle
Open DevTools → Network → reload. Click any application script and look at its sourcemap. Inside, search `sources[]` for entries matching `node_modules/@sqlite.org/sqlite-wasm/` — every match confirms the package is bundled. The matching `sourcesContent[i]` for `node_modules/@sqlite.org/sqlite-wasm/package.json` gives you the exact installed version.
- 3
Read the version directly from package.json
Run `jq -r '. as $m | $m.sources | to_entries[] | select(.value | endswith("node_modules/@sqlite.org/sqlite-wasm/package.json")) | $m.sourcesContent[.key] | fromjson | .version' bundle.js.map`. Sourcemap Explorer automates the same query in the popup.
Recent versions
FAQ
What is @sqlite.org/sqlite-wasm used for?
SQLite Wasm conveniently wrapped as an ES Module.
How can I tell if a website is using @sqlite.org/sqlite-wasm?
Open the page in Chrome with the Sourcemap Explorer extension installed and read the Stack tab. We catch `@sqlite.org/sqlite-wasm` from two complementary signals: `node_modules/@sqlite.org/sqlite-wasm/` paths inside the JavaScript sourcemap, and the embedded `package.json` we read for exact-version detection. Without the extension you can do the same lookup manually in DevTools — the steps are listed in the "How Sourcemap Explorer detects" section above.
What is the latest version of @sqlite.org/sqlite-wasm?
3.53.0-build1, as published on the npm registry. The "Recent versions" table on this page lists the most recent 5 releases with their release dates. Sourcemap Explorer reports the version actually bundled into a site, which can lag the latest release by months on real-world deployments.
Where can I read more?
Project homepage: https://github.com/sqlite/sqlite-wasm#readme. Source code: https://github.com/sqlite/sqlite-wasm. Published on npm: https://www.npmjs.com/package/@sqlite.org/sqlite-wasm. Licensed as Apache-2.0.
Detected by Sourcemap Explorer
When a bundle ships sourcemaps, we read the embedded package.json for @sqlite.org/sqlite-wasm and report the precise version. Without sourcemaps, an import / require in the page's scripts is enough to flag it.