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

@monlite/wasm

v0.2.2

Published

Run @monlite/core in the browser (or anywhere) on SQLite-WASM via sql.js — a custom driver.

Downloads

1,132

Readme

@monlite/wasm

Run @monlite/core in the browser on SQLite compiled to WebAssembly, via sql.js.

monlite's driver-adapter seam means the browser is just another backend — the document and structured collection API, reactive watch(), and the kv/queue/cron harness all run unchanged, in-browser, no server required.

npm install @monlite/core @monlite/wasm sql.js

Quick start

initSqlJs is async (it loads the .wasm binary), so initialise it first, then hand the module to wasmDriver. createDb itself stays synchronous.

import initSqlJs from "sql.js";
import { createDb } from "@monlite/core";
import { wasmDriver } from "@monlite/wasm";

const SQL = await initSqlJs({
  locateFile: (file) => `/sqljs/${file}`, // point at where your bundler serves sql-wasm.wasm
});

const db = createDb(":memory:", { driver: wasmDriver(SQL) });

await db.collection("notes").create({ data: { title: "hello", body: "from the browser" } });
const notes = await db.collection("notes").findMany({ where: { title: "hello" } });

Bundler note: copy node_modules/sql.js/dist/sql-wasm.wasm to a served path and return it from locateFile. For Vite, put it in public/sqljs/.

Persistence

sql.js holds the database in memory. To persist it across page loads, snapshot the bytes to IndexedDB (or OPFS) and restore them on startup:

import { wasmDriver, exportDatabase } from "@monlite/wasm";

// On startup: restore from IndexedDB if a previous snapshot exists
const saved = await idbGet("monlite-db"); // Uint8Array | undefined
const db = createDb(":memory:", { driver: wasmDriver(SQL, { data: saved }) });

// After writes (debounced) or on beforeunload: persist
async function persist() {
  await idbSet("monlite-db", exportDatabase(db));
}

A reactive debounce works well here: subscribe with collection.watch() and call persist() on a trailing debounce after each change.

Sync with the server

A monlite WASM database uses the same SQLite format as the Node backends, so it syncs with a server or another device through @monlite/sync like any other monlite database.

Notes

  • sql.js runs in Node as well, so @monlite/wasm is covered by the normal test suite.
  • Snapshotting rewrites the whole file, which is fine up to tens of MB. For larger, write-heavy databases the planned next step is a driver over @sqlite.org/sqlite-wasm with the OPFS VFS (incremental persistence via a Web Worker). Same Driver interface, drop-in.

License

MIT