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

@culpritsql/devtools

v0.6.0

Published

In-app SQL DevTools HUD, N+1 burst detector, and interactive EXPLAIN, deadlock, and Extended Events (.xel) inspector for React and Node.js.

Readme

npm React 18 | 19 Node 20+ TypeScript License: MIT

In-app SQL DevTools HUD, automatic N+1 burst detector, and interactive EXPLAIN plan inspector for React and Node.js. Powered by @culpritsql/plans WebAssembly and @culpritsql/plan-viewer.

Quickstart · Integrations · React HUD · Server Collector · API


Highlights

  • Floating SQL HUD (⚡ SQL · 12 · 1 N+1): Live query counter with green/amber/coral health dot and docked drawer (Queries · N+1 Bursts · Plan Inspector).
  • Automatic N+1 burst detection: Canonical SQL fingerprinting strips comments, literals, $1/?/:param, and IN (?, ?, ...) lists to group repeated queries per HTTP request and suggest JOIN or WHERE id = ANY($1) batching fixes.
  • Request correlation (AsyncLocalStorage): Tags every SQL query executed inside a route handler with its HTTP route badge (GET /api/orders).
  • Zero-dependency driver & diagnostics_channel hooks: Native support for Reylo (reylo:query), pg, mysql2, better-sqlite3 / node:sqlite, Prisma, and Drizzle.
  • Safe auto-EXPLAIN + instant .xel & deadlock inspector: Runs read-only EXPLAIN on slow single-statement SELECT queries via @culpritsql/plans Wasm, or paste/drop any PostgreSQL, MySQL, MariaDB, SQLite, YugabyteDB, or SQL Server .sqlplan, deadlock graph, or binary .xel / Extended Events XML directly inside the drawer.
  • Strict CSS & bundler isolation: Scoped to .culprit-dt (never mutates host body or <button> styles), and Node builtins live strictly behind @culpritsql/devtools/server.

Quickstart

npm install @culpritsql/devtools

1. Instrument your server & expose /__culprit

// lib/devtools.ts (Node.js server)
import { Pool } from "pg";
import {
  CulpritCollector,
  createDevtoolsHandler,
  instrumentPg,
} from "@culpritsql/devtools/server";

export const sqlCollector = new CulpritCollector({
  slowThresholdMs: 20,
  nPlusOneThreshold: 5,
});

// Optional: capture Reylo, pg, and mysql2 diagnostics_channel events automatically
sqlCollector.subscribeDiagnosticsChannels();

export const pool = instrumentPg(new Pool({ connectionString: process.env.DATABASE_URL }), {
  collector: sqlCollector,
  autoExplain: true,
});

export const devtoolsHandler = createDevtoolsHandler(sqlCollector);

2. Mount <CulpritDevtools /> in your React layout

// app/layout.tsx or src/App.tsx
import { CulpritDevtools } from "@culpritsql/devtools/react";
import "@culpritsql/devtools/styles.css";

export function DevOverlay() {
  if (process.env.NODE_ENV === "production") return null;
  return <CulpritDevtools endpoint="/__culprit" position="bottom-right" theme="dark" />;
}

Live Full-Stack Playground

Run the zero-Docker SQLite + React 19 + WebAssembly playground in demo/ to trigger live N+1 query bursts, compare batched fixes, emit reylo:query diagnostics_channel telemetry, and inspect interactive EXPLAIN flow graphs:

git clone https://github.com/culpritsql/culprit-devtools.git
cd culprit-devtools && bun install && bun run demo
# Open http://127.0.0.1:4321

Framework & Driver Integrations

Reylo (diagnostics_channel)

Reylo emits structured query telemetry on reylo:query. Subscribe once at startup to capture timings, row counts, parameters, and request correlation with zero wrapper code:

import { CulpritCollector } from "@culpritsql/devtools/server";

export const collector = new CulpritCollector();
collector.subscribeDiagnosticsChannels(["reylo:query"]);

Next.js App Router

// app/api/__culprit/[...slug]/route.ts
import { createDevtoolsHandler } from "@culpritsql/devtools/server";
import { sqlCollector } from "@/lib/devtools";

const handler = createDevtoolsHandler(sqlCollector, { basePath: "/api/__culprit" });

export const GET = handler;
export const POST = handler;

Wrap Route Handlers or Server Actions with sqlCollector.withRequest("GET /api/orders", () => ...) and point <CulpritDevtools endpoint="/api/__culprit" /> at the route.

Hono

import { Hono } from "hono";
import { CulpritCollector, createDevtoolsHandler } from "@culpritsql/devtools/server";

const collector = new CulpritCollector();
const devtools = createDevtoolsHandler(collector);
const app = new Hono();

app.all("/__culprit/*", (c) => devtools(c.req.raw));
app.use("*", (c, next) => collector.withRequest(`${c.req.method} ${c.req.path}`, next));

Express / Node http

createNodeDevtoolsMiddleware serves /__culprit/* and automatically wraps downstream Express routes in collector.withRequest("METHOD /path", ...):

import express from "express";
import { CulpritCollector, createNodeDevtoolsMiddleware } from "@culpritsql/devtools/server";

const app = express();
const collector = new CulpritCollector();

app.use(createNodeDevtoolsMiddleware(collector));

pg, mysql2, and SQLite

import {
  instrumentPg,
  instrumentMysql,
  instrumentSqlite,
} from "@culpritsql/devtools/server";

const pgPool = instrumentPg(rawPgPool, { autoExplain: true });
const mysqlPool = instrumentMysql(rawMysqlPool, { autoExplain: true });
const sqliteDb = instrumentSqlite(rawBetterSqlite3Db, { autoExplain: true });

Drizzle ORM & Prisma

import { drizzle } from "drizzle-orm/node-postgres";
import { sqlCollector, pool } from "./devtools";

// Passing an instrumented pg pool captures exact execution timings + auto-EXPLAIN:
export const db = drizzle(pool);

// Or attach a lightweight Drizzle logger directly:
export const loggedDb = drizzle(rawPool, {
  logger: sqlCollector.createDrizzleLogger("postgres"),
});

// Prisma client query event hook:
prisma.$on("query", (event) => {
  sqlCollector.recordQuery({
    sql: event.query,
    durationMs: event.duration,
    params: event.params,
    engine: "postgres",
  });
});

React HUD & Drawer

<CulpritDevtools /> works with live polling (endpoint="/__culprit"), SSR (initialSnapshot), or completely offline in Storybook and tests (snapshot={...}).

| Prop | Type | Default | Description | | --- | --- | --- | --- | | endpoint | string | "/__culprit" | Base URL for /snapshot, /clear, and /parse | | snapshot | DevtoolsSnapshot | undefined | Controlled snapshot (disables background polling) | | initialSnapshot | DevtoolsSnapshot | undefined | Initial data for SSR and first client paint | | pollIntervalMs | number | 1500 | Polling cadence in ms (<= 0 disables polling) | | position | "bottom-right" \| "bottom-left" \| "top-right" \| "top-left" | "bottom-right" | Corner placement for the floating trigger pill | | theme | "dark" \| "light" \| "system" | "dark" | Theme applied to the drawer and <PlanViewer /> | | defaultOpen | boolean | false | Render with the drawer open initially | | defaultTab | "queries" \| "bursts" \| "plan" | "queries" | Initial drawer tab |


Server Collector & Security

  • Disabled in production by default: CulpritCollector becomes a zero-allocation no-op when NODE_ENV === "production", and createDevtoolsHandler returns 403 Forbidden unless allowProduction: true is explicitly configured.
  • Loopback-only guard: createDevtoolsHandler and createNodeDevtoolsMiddleware reject non-loopback Host, X-Forwarded-For, and socket addresses (403 Forbidden) unless allowRemote: true is passed.
  • Read-only autoExplain guard: Auto-EXPLAIN runs strictly on single-statement SELECT / WITH ... SELECT queries containing zero data-modifying keywords, tagged with /* culprit */ so explain queries never recurse.

Subpath Exports

| Import Path | Environment | Exports | | --- | --- | --- | | @culpritsql/devtools | Browser / SSR / Universal | CulpritDevtools, ExtendedEventsViewer, DeadlockViewer, PlanViewer, normalizeSqlForFingerprint, fingerprintSql, detectNPlusOneAdvice, shared types | | @culpritsql/devtools/react | Browser / SSR | CulpritDevtools, ExtendedEventsViewer, DeadlockViewer, PlanViewer, and React prop types | | @culpritsql/devtools/server | Node.js / Bun (>=20) | CulpritCollector, createDevtoolsHandler, createNodeDevtoolsMiddleware, instrumentPg, instrumentMysql, instrumentSqlite, parseExplainText, parseDeadlockText, parseExtendedEventsXmlText, parseXelBytes | | @culpritsql/devtools/styles.css | CSS | Scoped .culprit-dt + @culpritsql/plan-viewer styles |

License

MIT