You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@sentry/nextjs

Package Overview
Dependencies
17
Maintainers
11
Versions
297
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/nextjs

Official Sentry SDK for Next.js


Version published
Maintainers
11
Created

Package description

What is @sentry/nextjs?

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.

What are @sentry/nextjs's main functionalities?

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'
});

Other packages similar to @sentry/nextjs

Changelog

Source

8.0.0-beta.6

This beta release contains various bugfixes and improvements for the v8 beta cycle.

  • feat: Add tunnel support to multiplexed transport (#11806)
  • feat: Export spanToBaggageHeader utility (#11881)
  • feat(browser): Disable standalone http.client spans (#11879)
  • feat(ember): Update ember dependencies (#11753)
  • feat(fedback): Convert CDN bundles to use async feedback for lower bundle sizes (#11791)
  • feat(feedback): Add captureFeedback method (#11428)
  • feat(feedback): Have screenshot by default (#11839)
  • feat(integrations): Add zod integration (#11144)
  • feat(ioredis): Add integration for ioredis (#11856)
  • feat(nextjs): Add transaction name to scope of server component (#11850)
  • feat(nextjs): Be smarter in warning about old ways of init configuration (#11882)
  • feat(nextjs): Set transaction names on scope for route handlers and generation functions (#11869)
  • feat(node): Support Node 22 (#11871)
  • fix(angular): Run tracing calls outside Angular (#11748)
  • fix(feedback): Be consistent about whether screenshot should and can render (#11859)
  • fix(nestjs): Ensure Nest.js interceptor works with non-http context (#11880)
  • fix(node): Fix nest.js error handler (#11874)
  • fix(react): Fix react router v4/v5 instrumentation (#11855)
  • ref: Add geo location types (#11847)

Readme

Source

Sentry

Official Sentry SDK for Next.js

npm version npm dm npm dt

Compatibility

Currently, the minimum Next.js supported version is 11.2.0.

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, 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: [
    // ...
  ],
});

FAQs

Package last updated on 03 May 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc