{"id":14156606,"url":"https://github.com/sqlite/sqlite-wasm","last_synced_at":"2026-01-26T10:14:48.774Z","repository":{"id":153325292,"uuid":"627300541","full_name":"sqlite/sqlite-wasm","owner":"sqlite","description":"SQLite Wasm conveniently wrapped as an ES Module.","archived":false,"fork":false,"pushed_at":"2026-01-22T08:16:46.000Z","size":5823,"stargazers_count":919,"open_issues_count":3,"forks_count":79,"subscribers_count":15,"default_branch":"main","last_synced_at":"2026-01-22T22:23:02.882Z","etag":null,"topics":["esm","opfs","origin-private-file-system","sqlite","sqlite-wasm","sqlite-webassembly","sqlite3","sqlite3-wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqlite.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-13T07:24:18.000Z","updated_at":"2026-01-22T08:16:50.000Z","dependencies_parsed_at":"2023-11-27T10:25:44.124Z","dependency_job_id":"5312160f-a694-4c3e-84d9-08f83236850b","html_url":"https://github.com/sqlite/sqlite-wasm","commit_stats":null,"previous_names":["sqlite/sqlite-wasm","tomayac/sqlite-wasm"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/sqlite/sqlite-wasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlite%2Fsqlite-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlite%2Fsqlite-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlite%2Fsqlite-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlite%2Fsqlite-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqlite","download_url":"https://codeload.github.com/sqlite/sqlite-wasm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqlite%2Fsqlite-wasm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28774301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T09:42:00.929Z","status":"ssl_error","status_checked_at":"2026-01-26T09:42:00.591Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esm","opfs","origin-private-file-system","sqlite","sqlite-wasm","sqlite-webassembly","sqlite3","sqlite3-wasm","webassembly"],"created_at":"2024-08-17T08:07:04.409Z","updated_at":"2026-01-26T10:14:48.744Z","avatar_url":"https://github.com/sqlite.png","language":"JavaScript","readme":"# SQLite Wasm\n\nSQLite Wasm conveniently wrapped as an ES Module.\n\n## Bug reports\n\n\u003e [!Warning]\n\u003e\n\u003e This project wraps the code of\n\u003e [SQLite Wasm](https://sqlite.org/wasm/doc/trunk/index.md) with _no_ changes,\n\u003e apart from added TypeScript types. Please do _not_ file issues or feature\n\u003e requests regarding the underlying SQLite Wasm code here. Instead, please\n\u003e follow the\n\u003e [SQLite bug filing instructions](https://www.sqlite.org/src/wiki?name=Bug+Reports).\n\u003e Filing TypeScript type related issues and feature requests is fine.\n\n## Node.js support\n\n\u003e [!Warning]\n\u003e\n\u003e Node.js is currently only supported for in-memory databases without\n\u003e persistence.\n\n## Installation\n\n```bash\nnpm install @sqlite.org/sqlite-wasm\n```\n\n## Usage\n\nThere are three ways to use SQLite Wasm:\n\n- [in the main thread with a wrapped worker](#in-a-wrapped-worker-with-opfs-if-available)\n  (🏆 preferred option)\n- [in a worker](#in-a-worker-with-opfs-if-available)\n- [in the main thread](#in-the-main-thread-without-opfs)\n\nOnly the worker versions allow you to use the origin private file system (OPFS)\nstorage back-end.\n\n### In a wrapped worker (with OPFS if available):\n\n\u003e [!Warning]\n\u003e\n\u003e For this to work, you need to set the following headers on your server:\n\u003e\n\u003e `Cross-Origin-Opener-Policy: same-origin`\n\u003e\n\u003e `Cross-Origin-Embedder-Policy: require-corp`\n\n```js\nimport { sqlite3Worker1Promiser } from '@sqlite.org/sqlite-wasm';\n\nconst log = console.log;\nconst error = console.error;\n\nconst initializeSQLite = async () =\u003e {\n  try {\n    log('Loading and initializing SQLite3 module...');\n\n    const promiser = await new Promise((resolve) =\u003e {\n      const _promiser = sqlite3Worker1Promiser({\n        onready: () =\u003e resolve(_promiser),\n      });\n    });\n\n    log('Done initializing. Running demo...');\n\n    const configResponse = await promiser('config-get', {});\n    log('Running SQLite3 version', configResponse.result.version.libVersion);\n\n    const openResponse = await promiser('open', {\n      filename: 'file:mydb.sqlite3?vfs=opfs',\n    });\n    const { dbId } = openResponse;\n    log(\n      'OPFS is available, created persisted database at',\n      openResponse.result.filename.replace(/^file:(.*?)\\?vfs=opfs$/, '$1'),\n    );\n    // Your SQLite code here.\n  } catch (err) {\n    if (!(err instanceof Error)) {\n      err = new Error(err.result.message);\n    }\n    error(err.name, err.message);\n  }\n};\n\ninitializeSQLite();\n```\n\nThe `promiser` object above implements the\n[Worker1 API](https://sqlite.org/wasm/doc/trunk/api-worker1.md#worker1-methods).\n\n### In a worker (with OPFS if available):\n\n\u003e [!Warning]\n\u003e\n\u003e For this to work, you need to set the following headers on your server:\n\u003e\n\u003e `Cross-Origin-Opener-Policy: same-origin`\n\u003e\n\u003e `Cross-Origin-Embedder-Policy: require-corp`\n\n```js\n// In `main.js`.\nconst worker = new Worker('worker.js', { type: 'module' });\n```\n\n```js\n// In `worker.js`.\nimport sqlite3InitModule from '@sqlite.org/sqlite-wasm';\n\nconst log = console.log;\nconst error = console.error;\n\nconst start = (sqlite3) =\u003e {\n  log('Running SQLite3 version', sqlite3.version.libVersion);\n  const db =\n    'opfs' in sqlite3\n      ? new sqlite3.oo1.OpfsDb('/mydb.sqlite3')\n      : new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');\n  log(\n    'opfs' in sqlite3\n      ? `OPFS is available, created persisted database at ${db.filename}`\n      : `OPFS is not available, created transient database ${db.filename}`,\n  );\n  // Your SQLite code here.\n};\n\nconst initializeSQLite = async () =\u003e {\n  try {\n    log('Loading and initializing SQLite3 module...');\n    const sqlite3 = await sqlite3InitModule();\n    log('Done initializing. Running demo...');\n    start(sqlite3);\n  } catch (err) {\n    error('Initialization error:', err.name, err.message);\n  }\n};\n\ninitializeSQLite();\n```\n\nThe `db` object above implements the\n[Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).\n\n### In the main thread (without OPFS):\n\n```js\nimport sqlite3InitModule from '@sqlite.org/sqlite-wasm';\n\nconst log = console.log;\nconst error = console.error;\n\nconst start = (sqlite3) =\u003e {\n  log('Running SQLite3 version', sqlite3.version.libVersion);\n  const db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');\n  // Your SQLite code here.\n};\n\nconst initializeSQLite = async () =\u003e {\n  try {\n    log('Loading and initializing SQLite3 module...');\n    const sqlite3 = await sqlite3InitModule();\n    log('Done initializing. Running demo...');\n    start(sqlite3);\n  } catch (err) {\n    error('Initialization error:', err.name, err.message);\n  }\n};\n\ninitializeSQLite();\n```\n\nThe `db` object above implements the\n[Object Oriented API #1](https://sqlite.org/wasm/doc/trunk/api-oo1.md).\n\n## Usage with vite\n\nIf you are using [vite](https://vitejs.dev/), you need to add the following\nconfig option in `vite.config.js`:\n\n```js\nimport { defineConfig } from 'vite';\n\nexport default defineConfig({\n  server: {\n    headers: {\n      'Cross-Origin-Opener-Policy': 'same-origin',\n      'Cross-Origin-Embedder-Policy': 'require-corp',\n    },\n  },\n  optimizeDeps: {\n    exclude: ['@sqlite.org/sqlite-wasm'],\n  },\n});\n```\n\nCheck out a\n[sample project](https://stackblitz.com/edit/vitejs-vite-ttrbwh?file=main.js)\nthat shows this in action.\n\n## Demo\n\nSee the [demo](https://github.com/sqlite/sqlite-wasm/tree/main/demo) folder for\nexamples of how to use this in the main thread and in a worker. (Note that the\nworker variant requires special HTTP headers, so it can't be hosted on GitHub\nPages.) An example that shows how to use this with vite is available on\n[StackBlitz](https://stackblitz.com/edit/vitejs-vite-ttrbwh?file=main.js).\n\n## Projects using this package\n\nSee the list of\n[npm dependents](https://www.npmjs.com/browse/depended/@sqlite.org/sqlite-wasm)\nfor this package.\n\n## Deploying a new version\n\n(These steps can only be executed by maintainers.)\n\n1. Manually trigger the\n   [GitHub Actions workflow](../../actions/workflows/build-wasm.yml). By\n   default, it uses the latest SQLite tag. This pull request will contain the\n   latest `sqlite3.wasm` and related bindings.\n\n2. Once the above pull request is validated and merged, update the version\n   number in `package.json`, reflecting the current\n   [SQLite version number](https://sqlite.org/download.html) and add a build\n   identifier suffix like `-build1`. The complete version number should read\n   something like `3.41.2-build1`.\n\n## Building the SQLite Wasm locally\n\n1.  Build the Docker image:\n\n    ```bash\n    docker build -t sqlite-wasm-builder:env .\n    ```\n\n2.  Run the build:\n\n    **Unix (Linux/macOS):**\n\n    ```bash\n    docker run --rm \\\n      -e SQLITE_REF=\"master\" \\\n      -v \"$(pwd)/out\":/out \\\n      -v \"$(pwd)/src/bin\":/src/bin \\\n      sqlite-wasm-builder:env build\n    ```\n\n    **Windows (PowerShell):**\n\n    ```powershell\n    docker run --rm `\n      -e SQLITE_REF=\"master\" `\n      -v \"${PWD}/out:/out\" `\n      -v \"${PWD}/src/bin:/src/bin\" `\n      sqlite-wasm-builder:env build\n    ```\n\n    **Windows (Command Prompt):**\n\n    ```cmd\n    docker run --rm ^\n      -e SQLITE_REF=\"master\" ^\n      -v \"%cd%/out:/out\" ^\n      -v \"%cd%/src/bin:/src/bin\" ^\n      sqlite-wasm-builder:env build\n    ```\n\n## Running tests\n\nThe test suite consists of Node.js tests and browser-based tests (using Vitest\nBrowser Mode). Tests aim to sanity-check the exported scripts. We test for\ncorrect exports and **very** basic functionality.\n\n1.  Install dependencies:\n\n    ```bash\n    npm install\n    ```\n\n2.  Install Playwright browsers (required for browser tests):\n\n    ```bash\n    npx playwright install chromium --with-deps --no-shell\n    ```\n\n3.  Run all tests:\n\n    ```bash\n    npm test\n    ```\n\n## License\n\nApache 2.0.\n\n## Acknowledgements\n\nThis project is based on [SQLite Wasm](https://sqlite.org/wasm), which it\nconveniently wraps as an ES Module and publishes to npm as\n[`@sqlite.org/sqlite-wasm`](https://www.npmjs.com/package/@sqlite.org/sqlite-wasm).\n","funding_links":[],"categories":["Extensions","JavaScript","webassembly"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlite%2Fsqlite-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqlite%2Fsqlite-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqlite%2Fsqlite-wasm/lists"}