GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sqlite/sqlite-wasm: SQLite Wasm conveniently wrapped as an ES Module.

BranchesTags
Open more actions menu

Latest commit

 

History

277 Commits
277 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
demos
demos
 
 
scripts
scripts
 
 
src
src
 
 
.dockerignore
.dockerignore
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
lefthook.yml
lefthook.yml
 
 
oxfmt.config.ts
oxfmt.config.ts
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
tsdown.config.ts
tsdown.config.ts
 
 
vitest.config.ts
vitest.config.ts
 
 

Repository files navigation

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:

  • in a worker
  • in the main thread

Only the worker versions allow you to use the origin private file system (OPFS) storage back-end.

In a worker (with OPFS):

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.ts`.
const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' });
// In `worker.ts`.
import sqlite3InitModule from '@sqlite.org/sqlite-wasm';

const sqlite3 = await sqlite3InitModule();

console.log('Running SQLite3 version', sqlite3.version.libVersion);

const db = new sqlite3.oo1.OpfsDb('/mydb.sqlite3');

try {
  // Your SQLite code here.
} finally {
  db.close();
}

The db object above implements the Object-Oriented API #1.

In the main thread (without OPFS):

import sqlite3InitModule from '@sqlite.org/sqlite-wasm';

const sqlite3 = await sqlite3InitModule();

console.log('Running SQLite3 version', sqlite3.version.libVersion);

const db = new sqlite3.oo1.DB('/mydb.sqlite3', 'ct');

try {
  // Your SQLite code here.
} finally {
  db.close();
}

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.ts:

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'],
  },
});

See our OPFS and SAH pool examples for working Vite projects.

Examples

  • Main thread
  • Worker
  • OPFS
  • OPFS with Web Locks
  • Key-value storage (kvvfs)
  • SAH pool with Vite
  • SAH pool with webpack
  • SAH pool with Parcel
  • SAH pool with Rsbuild

Projects using this package

See the list of npm dependents for this package.

Contributing

See CONTRIBUTING.md for deployment, local build, and testing instructions.

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.

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.

About

SQLite Wasm conveniently wrapped as an ES Module.

Topics

esmopfsorigin-private-file-systemsqlitesqlite-wasmsqlite-webassemblysqlite3sqlite3-wasmwebassembly

Resources

Readme
License

Contributing

Contributing
Activity

Stars

1.1k stars

Watchers

14 watching

Forks

91 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.