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

@meck93/bun-sqlite-change-hooks

v0.1.4

Published

SQLite change notification hooks for Bun. Uses a C extension (`sqlite3_update_hook`) with a ring-buffer and polling service to deliver row-level change events (INSERT/UPDATE/DELETE).

Readme

@meck93/bun-sqlite-change-hooks

SQLite change notification hooks for Bun. Uses a C extension (sqlite3_update_hook) with a ring-buffer and polling service to deliver row-level change events (INSERT/UPDATE/DELETE).

Bun has no native sqlite3_update_hook support, so this package fills the gap.

Install

bun add @meck93/bun-sqlite-change-hooks

Usage

import { configureCustomSqlite, SQLiteChangeHookService } from "@meck93/bun-sqlite-change-hooks";
import Database from "bun:sqlite";

// macOS: use Homebrew SQLite (required for extension loading)
configureCustomSqlite();

const db = new Database("my.db");

const hooks = new SQLiteChangeHookService({
  onChange: event => {
    console.log(event); // { operation, tableName, rowId, timestamp }
  },
  config: { pollIntervalMs: 50, maxChangesPerPoll: 256 }, // optional
  logger: console, // optional
});

await hooks.initialize(db);

// ... changes to db will trigger onChange callbacks

hooks.shutdown();

Worker Mode (Optional)

When your SQLite connection lives inside a Bun worker, run the hook service in the worker and forward events to the main thread with SQLiteChangeHookWorkerClient.

Worker file

import { configureCustomSqlite, createSQLiteChangeHookWorkerRuntime } from "@meck93/bun-sqlite-change-hooks";
import Database from "bun:sqlite";

configureCustomSqlite();

const database = new Database("my.db");
createSQLiteChangeHookWorkerRuntime({
  database,
  config: { pollIntervalMs: 50, maxChangesPerPoll: 256 },
});

Main thread

import { SQLiteChangeHookWorkerClient } from "@meck93/bun-sqlite-change-hooks";

const worker = new Worker(new URL("./sqlite.worker.ts", import.meta.url), { type: "module" });

const hooks = new SQLiteChangeHookWorkerClient({
  worker,
  onChange: event => {
    console.log(event);
  },
  requestTimeoutMs: 5000, // optional
});

await hooks.initialize();

// ...

await hooks.shutdown();
hooks.dispose();
worker.terminate();

API

SQLiteChangeHookService

  • new SQLiteChangeHookService({ onChange, config?, logger? }) — create service
  • initialize(database) — compile + load C extension, start polling
  • shutdown() — stop polling, release resources
  • isEnabled() / isInitialized() — status checks
  • getHealthStatus() — health info object

createSQLiteChangeHookWorkerRuntime

  • createSQLiteChangeHookWorkerRuntime({ database, config?, logger? }) — start worker message handling
  • Handles sqlite-change-hooks:init and sqlite-change-hooks:shutdown protocol messages
  • Emits sqlite-change-hooks:event messages with DatabaseChangePayload
  • Returns { isInitialized, dispose }

SQLiteChangeHookWorkerClient

  • new SQLiteChangeHookWorkerClient({ worker, onChange, requestTimeoutMs?, logger? })
  • initialize(config?) — starts the worker-side hook service
  • shutdown() — stops the worker-side hook service
  • dispose() — removes listeners and rejects pending requests
  • isInitialized() — client-side initialization status

configureCustomSqlite()

On macOS, configures Bun to use Homebrew's SQLite (supports extension loading). No-op on other platforms.

resolveSqliteIncludeDir()

Resolves the SQLite header include directory for C extension compilation.

Environment Variables

| Variable | Description | | ------------------------------------ | ---------------------------------------------- | | SQLITE_CHANGE_HOOKS_ENABLED | Enable/disable hooks (default: true) | | SQLITE_CHANGE_POLL_INTERVAL_MS | Poll interval in ms (default: 50) | | SQLITE_CHANGE_MAX_CHANGES_PER_POLL | Max events per poll (default: 256) | | SQLITE_CHANGE_HOOKS_DEBUG | Enable debug logging (default: false) | | SQLITE_CHANGE_HOOKS_BUILD_DIR | Extension build directory (default: OS tmpdir) | | SQLITE_CHANGE_HOOKS_EXTENSION_PATH | Pre-built extension path (skips compilation) | | SQLITE_CUSTOM_LIB_PATH | Custom SQLite library path (macOS) | | SQLITE_CHANGE_HOOKS_INCLUDE_DIR | SQLite header include directory |

License

MIT