@g8scope/nextjs wires capture into Next.js’s instrumentation hooks: register runs at start-up (Next.js 13.4+) and onRequestError is called for every server-side error (Next.js 15). It is fire-and-forget and never throws into your app.
Install from GitHub. Not on npm yet. Build bliptrace-js and bliptrace-nextjs side by side, the same way as for Express, then install both tarballs into your app in one
npm install.
git clone https://github.com/bliptrace/bliptrace-js
git clone https://github.com/bliptrace/bliptrace-nextjs
(cd bliptrace-js && npm install && npm run build && npm pack)
(cd bliptrace-nextjs && npm install && npm run build && npm pack)
npm install /path/to/bliptrace-js/g8scope-js-1.0.0.tgz /path/to/bliptrace-nextjs/g8scope-nextjs-1.0.0.tgz
Wire it up
// instrumentation.ts (project root, or src/)
import { register as registerBliptrace, onRequestError as onBliptraceRequestError } from '@g8scope/nextjs';
export function register() {
registerBliptrace({
key: process.env.BLIPTRACE_KEY,
endpoint: 'https://ingest.bliptrace.com',
environment: process.env.NODE_ENV,
release: process.env.BLIPTRACE_RELEASE,
});
}
export const onRequestError = onBliptraceRequestError;
Unhandled server errors are now reported with the request method, URL and headers (without authorization and cookie). Without a key, capture does nothing.
Report a handled error
import { captureException } from '@g8scope/nextjs';
try {
await doRiskyThing();
} catch (err) {
captureException(err, { context: { user: { id: userId } } });
throw err; // re-throw if Next should still handle it
}