Collect
Next.js emits spans for routes, renders and fetches. StackNext picks them up and adds Drizzle or Prisma query events and server errors.
Open source · MIT
StackNext collects the spans Next.js already emits, plus Drizzle and Prisma query events and server errors. Follow any request through the dashboard, CLI or a read-only MCP server.
npm install --save-dev @stacknext/cli @stacknext/next
Works with your existing stack
Adapters for Drizzle, Prisma and Playwright are optional.
01 / How it works
Next.js already emits the spans. StackNext adds query events and errors, then ties everything to the request that produced it. The result is a fixed-size sample that stays in memory.
Next.js emits spans for routes, renders and fetches. StackNext picks them up and adds Drizzle or Prisma query events and server errors.
Queries and errors are attached to the request that produced them, so a slow route leads to the span or query inside it.
Open a request in the dashboard and move from route to span to query. The CLI and MCP server read the same data.
02 / System
It listens on loopback, keeps a fixed-size window in memory, and writes runs, baselines, comparisons and snapshots under .stacknext. There is no backend to deploy.
03 / Access
The dashboard, CLI and MCP server all read the same local sample. Start in the browser, script a check, or hand the data to your coding agent.
The full sample: requests, traces, database queries, errors, diagnostics, snapshots and saved test runs.
stacknext devSee the dashboardCoverage, diagnostics, exports, snapshots, captures and comparisons from a terminal.
stacknext diagnoseCLI referenceA read-only server for coding agents: 20 tools, 5 prompts and GET requests over loopback.
stacknext mcpMCP reference04 / Dashboard
Every screenshot here is a real capture from the example app.

Requests, latency, database activity, errors, coverage and open findings, with the retention window always visible.
Windows Chrome · dark · 1600 × 1000

Open a route to see status, duration, server spans, database queries and any correlated errors on one timeline.
Windows Chrome · dark · 1600 × 1000

Drizzle and Prisma events share the request timeline. SQL text is redacted, and bind parameters are never captured.
Windows Chrome · dark · 1600 × 1000

Six rules run over the current sample: N+1 queries, slow requests, slow spans, repeated external HTTP, error fingerprints and server error responses.
Windows Chrome · dark · 1600 × 1000

Playwright scenarios are tied to the server trace that ran them, then compared with a saved baseline using medians and explicit thresholds.
Windows Chrome · dark · 1600 × 1000
Showing Overview: The current sample at a glance.
05 / Install
Three commands from install to a live request sample.
Run this inside the Next.js app, not at the workspace root.
npm install --save-dev @stacknext/cli @stacknext/nextinit writes stacknext.config.json and creates instrumentation.ts if it doesn't exist.
npx stacknext initdev starts the collector, runs your app's dev script, and writes a short-lived token to .stacknext/run.json with mode 0600.
npx stacknext devinit never overwrites an existing instrumentation file. If another monitor already owns it, add StackNext inside it.
type StackNextRequest = { path: string method: string headers: NodeJS.Dict<string | string[]>} type StackNextRequestContext = { routerKind: 'Pages Router' | 'App Router' routePath: string routeType: 'render' | 'route' | 'action' | 'proxy' renderSource?: string revalidateReason: 'on-demand' | 'stale' | undefined} // Generated by StackNext. Node.js runtime only; no-op without a local collector.export async function register(): Promise<void> { if (process.env.NEXT_RUNTIME !== 'nodejs') return const stacknext = await import('@stacknext/next') await stacknext.register()} export async function onRequestError( error: unknown, request: StackNextRequest, context: StackNextRequestContext,): Promise<void> { if (process.env.NEXT_RUNTIME !== 'nodejs') return const stacknext = await import('@stacknext/next') stacknext.onRequestError(error, request, context)}Generated by stacknext init. If instrumentation.ts already exists, init prints the lines to add instead.
import { drizzle } from 'drizzle-orm/better-sqlite3'import { createStackNextDrizzleLogger } from '@stacknext/drizzle' export const db = drizzle(client, { logger: createStackNextDrizzleLogger({ databaseSystem: 'sqlite' }),})Drizzle's Logger interface doesn't expose query duration. StackNext stores null and marks it as unmeasured.
import { PrismaClient } from '@prisma/client'import { instrumentPrismaClient } from '@stacknext/prisma' const prisma = new PrismaClient({ log: [{ emit: 'event', level: 'query' }],}) const stop = instrumentPrismaClient(prisma, { databaseSystem: 'postgresql',}) // Optional: call stop() during shutdown.Prisma only emits query events when query logging is enabled.
06 / Privacy
The collector listens on loopback and requires a token for writes. Bodies, headers, cookies, query values and SQL bind parameters are dropped before anything is stored.
Request data is redacted in your app process, then again in the collector. Only the redacted result reaches the in-memory store.
Loopback · token 0600 · two redaction passes
07 / FAQ
Short answers about the supported stack, privacy and what StackNext leaves out.
Still deciding? The limitations page covers the supported stack, how long data is kept and known gaps.
Read limitationsYes. It's open source under MIT. There's no account, paid plan or hosted service.
StackNext never uploads data. The collector listens on loopback and has no cloud, analytics or telemetry endpoint. If you connect a hosted coding agent over MCP, that agent's own policy applies to what it reads.
Next.js 15 and 16 with the App Router on the Node.js runtime. Edge runtime and the Pages Router are not supported.
No. StackNext uses documented Next.js telemetry, and registerStackNext() yields to an existing OpenTelemetry provider instead of starting a second SDK.
No. The core install is @stacknext/cli and @stacknext/next. The Drizzle, Prisma and Playwright integrations are optional.
No. It's a local development tool with a fixed-size sample. It has no TLS, multi-user auth or production hardening.
Yes. StackNext ships a read-only MCP server, so agents such as Claude Code, Codex and OpenCode can query the live sample and diagnostics. Findings still come from deterministic rules, not model output, and no AI provider is bundled.
Yes, for capture and compare workflows. Comparisons are report-only unless you pass --fail-on regression, --fail-on inconclusive or --fail-on any.
08 / Start
Install the packages, run init, then start your app with stacknext dev. No account or API key.
npm install --save-dev @stacknext/cli @stacknext/next