npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@haroonwaves/sqlite-wasm-easy

v0.2.5

Published

A simple, zero-config wrapper around @sqlite.org/sqlite-wasm

Downloads

1,728

Readme

@haroonwaves/sqlite-wasm-easy

A simple, zero-config wrapper around @sqlite.org/sqlite-wasm that runs SQLite in a Web Worker automatically.

Why?

The official @sqlite.org/sqlite-wasm is powerful but low-level. Setting it up with Web Workers, handling OPFS (Origin Private File System), and managing message passing can be complex.

sqlite-wasm-easy solves this by:

  • 🚀 Zero-Config: Works out of the box.
  • 🧵 Worker-First: Runs in a Web Worker by default to keep your main thread unblocked.
  • 💾 OPFS Support: Easy persistence configuration.
  • 🛡️ Type-Safe: Written in TypeScript with full type definitions.

Installation

npm install @haroonwaves/sqlite-wasm-easy

TypeScript Usage (Recommended)

For the best experience, define your schema interface and use the table() helper. This gives you strong typing and a cleaner API.

import { SQLiteWASM } from '@haroonwaves/sqlite-wasm-easy';

// 1. Define your schema
interface DatabaseSchema {
	users: {
		id: number;
		name: string;
		email: string;
		created_at: number;
	};
	posts: {
		id: number;
		title: string;
		content: string;
	};
}

// 2. Initialize with Schema
const db = new SQLiteWASM<DatabaseSchema>({ filename: 'my-app.db' });

await db.ready();

// 3. Use the table() API
// The '$' symbol is automatically replaced by the table name ('users')

// Create Table
await db.table('users').exec(`
  CREATE TABLE IF NOT EXISTS $ (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT
  )
`);

// Insert (Fully typed params are not enforced yet, but return types are)
await db
	.table('users')
	.run('INSERT INTO $ (name, email) VALUES (?, ?)', ['Alice', '[email protected]']);

// Query (Returns User[])
const allUsers = await db.table('users').query('SELECT * FROM $');

Configuration

The SQLiteWASM constructor accepts a configuration object to tailor the database to your needs.

const db = new SQLiteWASM({
	filename: 'my-database.db', // Required: Database file name
});

Available APIs

Use these APIs to interact with the database.

exec(sql, params?)

Execute SQL statements (e.g., CREATE, DELETE) without returning rows.

query<T>(sql, params?)

Execute a SELECT query and return an array of results.

run(sql, params?)

Execute a statement (e.g., INSERT, UPDATE) and return { lastInsertRowId, changes }.

transaction(callback)

Run multiple operations in a transaction. Automatically handles BEGIN, COMMIT, and ROLLBACK.

await db.transaction(async (tx) => {
	await tx.run('INSERT INTO log (action) VALUES (?)', ['update_start']);
	await tx.run('UPDATE users SET name = ? WHERE id = ?', ['Bob', 1]);
});

export() / import()

Export the entire database as a Uint8Array or import one from memory.

Type Reference

Key interfaces for better TypeScript integration.

SQLiteWASMConfig

interface SQLiteWASMConfig {
	filename: string; // Required: Database file name
	vfs?: {
		type?: 'opfs' | 'opfs-sahpool' | 'memdb'; // Default: 'opfs'
		poolConfig?: {
			// Only used when type is 'opfs-sahpool'
			initialCapacity?: number; // Default: 3
			clearOnInit?: boolean; // Default: false
			name?: string; // Default: 'sqlite-wasm-pool'
		};
	};
	pragma?: {
		journal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF'; // Default: 'WAL'
		synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA'; // Default: 'NORMAL'
		temp_store?: 'DEFAULT' | 'FILE' | 'MEMORY'; // Default: 'MEMORY'
		foreign_keys?: 'ON' | 'OFF'; // Default: undefined (not set)
	};
	logging?: {
		filterSqlTrace?: boolean; // Default: true
		print?: (message: string) => void; // Default: console.log
		printErr?: (message: string) => void; // Default: console.error
	};
}

Note: The opfs VFS requires your server to set COOP/COEP headers (Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp). If these headers are not available, use opfs-sahpool instead, which works without them.

RunResult

Returned by run() and table().run().

interface RunResult {
	lastInsertRowId?: number; // ID of the last inserted row
	changes?: number; // Number of rows affected
}