sqlite-wasm-easy is a zero-configuration wrapper around @sqlite.org/sqlite-wasm that
simplifies SQLite database usage in the browser.
- Zero Configuration - Works out of the box with sensible defaults
- Fully Configurable - VFS type, PRAGMA settings, logging options
- TypeScript First - Complete type safety and IntelliSense
- Web Worker Based - Non-blocking database operations
- Simple API - Only high-level methods (exec, query, run, transaction)
- Type Hints -
.table()method for typed access without CRUD methods
sqlite-wasm-easy/
├── src/
│ ├── index.ts # Main entry point
│ ├── core/
│ │ ├── database.ts # Main SQLiteWASM class
│ │ └── defaults.ts # Default configuration
│ ├── worker/
│ │ └── sqliteWorker.ts # Web Worker for SQLite operations
│ ├── types/
│ │ └── index.ts # All TypeScript type definitions
│ └── utils/ # (Reserved for future utilities)
├── dist/ # Built output
│ ├── index.js # Main bundle (14.5 KB)
│ ├── index.d.ts # TypeScript declarations
│ └── worker/
│ └── sqliteWorker.js # Worker bundle (5 KB)
├── examples/
│ ├── basic.html # Basic CRUD example
│ └── typed-schema.html # TypeScript schema example
├── package.json
├── tsconfig.json
├── vite.config.ts
├── README.md
└── LICENSE
Total bundle size: ~20 KB (gzipped: ~7 KB)
All aspects are configurable with sensible defaults:
interface SQLiteWASMConfig {
filename: string;
vfs?: {
type?: 'opfs-sahpool' | 'opfs' | 'memory';
poolConfig?: {
initialCapacity?: number; // Default: 3
clearOnInit?: boolean; // Default: false
name?: string; // Default: 'sqlite-wasm-pool'
};
};
pragma?: {
journal_mode?: JournalMode; // Default: 'WAL'
synchronous?: SynchronousMode; // Default: 'NORMAL'
temp_store?: TempStoreMode; // Default: 'MEMORY'
cache_size?: number;
page_size?: number;
foreign_keys?: 'ON' | 'OFF';
[key: string]: any; // Any custom PRAGMA
};
worker?: {
path?: string; // Custom worker path
};
logging?: {
filterSqlTrace?: boolean; // Default: true
print?: (msg: string) => void;
printErr?: (msg: string) => void;
};
}Only high-level methods (no CRUD):
class SQLiteWASM<Schema = any> {
ready(): Promise<void>;
exec(sql: string, params?: any[]): Promise<void>;
query<T>(sql: string, params?: any[]): Promise<T[]>;
run(sql: string, params?: any[]): Promise<RunResult>;
transaction(callback: (tx: Transaction) => Promise<void>): Promise<void>;
table<K extends keyof Schema>(name: K): TypedTable<Schema[K]>;
export(): Promise<Uint8Array>;
import(filename: string, data: Uint8Array): Promise<void>;
close(): Promise<void>;
delete(): Promise<void>;
}interface TypedTable<T> {
query<R = T>(sql: string, params?: any[]): Promise<R[]>;
exec(sql: string, params?: any[]): Promise<void>;
run(sql: string, params?: any[]): Promise<RunResult>;
}import { SQLiteWASM } from 'sqlite-wasm-easy';
const db = new SQLiteWASM({ filename: 'myapp.db' });
await db.ready();
await db.exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
await db.exec('INSERT INTO users (name) VALUES (?)', ['Alice']);
const users = await db.query('SELECT * FROM users');const db = new SQLiteWASM({
filename: 'myapp.db',
vfs: {
type: 'opfs-sahpool',
poolConfig: {
initialCapacity: 5,
clearOnInit: false,
name: 'custom-pool',
},
},
pragma: {
journal_mode: 'WAL',
synchronous: 'FULL',
foreign_keys: 'ON',
},
logging: {
filterSqlTrace: true,
},
});interface Schema {
users: { id: number; name: string; email: string };
posts: { id: number; userId: number; title: string };
}
const db = new SQLiteWASM<Schema>({ filename: 'app.db' });
const usersTable = db.table('users');
// Type-safe queries
const users = await usersTable.query('SELECT * FROM users');
// ^? { id: number; name: string; email: string }[]await db.transaction(async (tx) => {
await tx.exec('INSERT INTO users (name) VALUES (?)', ['Charlie']);
await tx.exec('UPDATE users SET active = 1 WHERE id = ?', [1]);
});| Aspect | Current (Supersorted) | sqlite-wasm-easy |
|---|---|---|
| Scope | App-specific | General-purpose package |
| Configuration | Hardcoded values | Fully configurable |
| Table API | Full ORM-like (insert, update, delete, etc.) | Type hints only (query, exec, run) |
| PRAGMA | Hardcoded (MEMORY, NORMAL) | User configurable |
| VFS | Hardcoded opfs-sahpool | User can choose (opfs-sahpool, opfs, memory) |
| Pool Config | Fixed (initialCapacity: 3) | Configurable |
| Console Filtering | Always on | Optional (configurable) |
✅ VFS Method - User chooses: opfs-sahpool, opfs, or memory ✅ Pool Settings -
initialCapacity, clearOnInit, name
✅ PRAGMA Settings - journal_mode, synchronous, temp_store, cache_size, etc.
✅ Logging - filterSqlTrace, custom print/printErr functions
✅ Worker Path - Custom worker location
- Main bundle:
dist/index.js(14.5 KB, gzipped: 5.5 KB) - Worker bundle:
dist/worker/sqliteWorker.js(5 KB, gzipped: 1.6 KB) - TypeScript declarations:
dist/index.d.ts
{
"name": "sqlite-wasm-easy",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": "./dist/index.js",
"./worker": "./dist/worker/sqliteWorker.js"
}
}cd sqlite-wasm-easy
npm install
npm run build # Build the package
npm run typecheck # Type checking only- Open
examples/basic.htmlin a browser (via dev server) - Open
examples/typed-schema.htmlfor TypeScript examples
# Test locally first
npm pack
# Publish to NPM (when ready)
npm publish- Multi-tab Coordination - Add BroadcastChannel support (from your tabCoordinator)
- Migration Helpers - Schema versioning utilities
- Batch Operations - Optimize multiple inserts
- Query Builder - Optional fluent query API (as separate package)
- IndexedDB Fallback - For browsers without OPFS support
- React Hooks -
useQuery,useMutationhelpers - Performance Monitoring - Built-in query timing and logging
✅ Chrome/Edge 102+
✅ Firefox (with OPFS support)
Peer Dependencies:
@sqlite.org/sqlite-wasm: ^3.49.0
Dev Dependencies:
typescript: ^5.7.3vite: ^6.1.0
MIT License
- The package is framework-agnostic (works with React, Vue, Svelte, vanilla JS)
- No bundler configuration needed (works with Vite, Webpack, Rollup)
- Fully tree-shakeable ES modules
- Zero runtime dependencies (except peer dependency on @sqlite.org/sqlite-wasm)
Created: January 22, 2026
Status: ✅ Ready for testing and publishing
Build: ✅ Successful (TypeScript compilation and Vite bundling)