Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@sentry/nextjs
Advanced tools
The @sentry/nextjs package is a JavaScript SDK for Sentry that provides error tracking and performance monitoring specifically tailored for Next.js applications. It helps developers to automatically capture exceptions, track performance issues, and improve the reliability of their Next.js applications.
Automatic Error Tracking
Automatically captures unhandled exceptions and errors in the Next.js application and sends them to Sentry for monitoring and analysis.
import * as Sentry from '@sentry/nextjs';
Sentry.init({ dsn: 'YOUR_DSN' });
Performance Monitoring
Enables performance monitoring to track the performance of server-side and client-side Next.js operations, providing insights into slow transactions and bottlenecks.
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'YOUR_DSN',
tracesSampleRate: 1.0
});
Custom Error Reporting
Allows developers to manually report custom errors or exceptions to Sentry, giving them control over what gets reported.
import * as Sentry from '@sentry/nextjs';
Sentry.captureException(new Error('Custom error message'));
Release Health Tracking
Tracks the health of releases by monitoring error rates and issues that affect end-users, helping developers to understand the impact of new releases.
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'YOUR_DSN',
release: 'my-project-name@1.0.0'
});
Bugsnag provides error monitoring for JavaScript applications, including Next.js. It offers similar features to Sentry, such as automatic error detection, custom error reporting, and release tracking. However, Bugsnag's interface and integrations may differ from Sentry's.
Raygun offers real-time error tracking and crash reporting for JavaScript applications. It includes features like user tracking, performance monitoring, and deployment tracking. Raygun's focus on user-centric metrics and detailed diagnostics provides a different perspective compared to Sentry.
LogRocket is a frontend application monitoring solution that combines session replay, performance monitoring, and error tracking. Unlike Sentry, which focuses on error and performance data, LogRocket provides insights into user interactions and experiences by recording user sessions.
Currently, the minimum Next.js supported version is 11.2.0
.
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, initialize it in the Next.js configuration, in the sentry.client.config.ts|js
file, and in the
Next.js Instrumentation Hook
(instrumentation.ts|js
).
// next.config.js
const { withSentryConfig } = require('@sentry/nextjs');
const nextConfig = {
experimental: {
// The instrumentation hook is required for Sentry to work on the serverside
instrumentationHook: true,
},
};
// Wrap the Next.js configuration with Sentry
module.exports = withSentryConfig(nextConfig);
// sentry.client.config.js or .ts
import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: '__DSN__',
// Your Sentry configuration for the Browser...
});
// instrumentation.ts
import * as Sentry from '@sentry/nextjs';
export function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
Sentry.init({
dsn: '__DSN__',
// Your Node.js Sentry configuration...
});
}
if (process.env.NEXT_RUNTIME === 'edge') {
Sentry.init({
dsn: '__DSN__',
// Your Edge Runtime Sentry configuration...
});
}
}
To set context information or send manual events, use the exported functions of @sentry/nextjs
.
import * as Sentry from '@sentry/nextjs';
// Set user information, as well as tags and further extras
Sentry.setExtra('battery', 0.7);
Sentry.setTag('user_mode', 'admin');
Sentry.setUser({ id: '4711' });
// Add a breadcrumb for future events
Sentry.addBreadcrumb({
message: 'My Breadcrumb',
// ...
});
// Capture exceptions, messages or manual events
Sentry.captureMessage('Hello, world!');
Sentry.captureException(new Error('Good bye'));
Sentry.captureEvent({
message: 'Manual',
stacktrace: [
// ...
],
});
Changes since 8.0.0-rc.3
feat(nextjs): Remove transpileClientSDK
(#11978)
As we are dropping support for Internet Explorer 11 and other other older browser versions wih version 8.0.0
, we are
also removing the transpileClientSDK
option from the Next.js SDK. If you need to support these browser versions,
please configure Webpack and Next.js to down-compile the SDK.
feat(serverless): Do not include performance integrations by default (#11998)
To keep Lambda bundle size reasonable, the SDK no longer ships with all performance (database) integrations by
default. Add the Sentry integrations of the databases and other tools you're using manually to your Sentry.init
call
by following
this guide.
Note that this change does not apply if you use the SDK with the Sentry AWS Lambda layer.
feat(feedback): Simplify public css configuration for feedback (#11985)
fix(feedback): Check for empty user (#11993)
fix(replay): Fix type for replayCanvasIntegration
(#11995)
fix(replay): Fix user activity not being updated in start()
(#12001)
FAQs
Official Sentry SDK for Next.js
The npm package @sentry/nextjs receives a total of 1,087,424 weekly downloads. As such, @sentry/nextjs popularity was classified as popular.
We found that @sentry/nextjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.