Official Sentry SDK for Next.js
![npm dt](https://img.shields.io/npm/dt/@sentry/nextjs.svg)
Links
Compatibility
Currently, the minimum Next.js supported version is 10.0.8
.
General
This package is a wrapper around @sentry/node
for the server and @sentry/react
for the client, with added functionality related to Next.js.
To use this SDK, init it in the Sentry config files.
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: "__DSN__",
});
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: "__DSN__",
});
To set context information or send manual events, use the exported functions of @sentry/nextjs
.
import * as Sentry from '@sentry/nextjs';
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
});
Sentry.addBreadcrumb({
message: 'My Breadcrumb',
});
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
message: 'Manual',
stacktrace: [
],
});