Integrations | Sentry for Next.js
Source URL: https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/integrations
Integrations | Sentry for Next.js
Section titled “Integrations | Sentry for Next.js”The Sentry SDK uses integrations to hook into the functionality of popular libraries to automatically instrument your application and give you the best data out of the box.
Integrations automatically add error instrumentation, performance instrumentation, and/or extra context information to your application. Some are enabled by default, but you can disable them or modify their settings.
Next.js can operate within three runtimes: the Node.js.js runtime, the browser runtime, and the Edge runtime. However, it’s important to note that not all integrations are compatible with all of these runtimes.
Depending on whether an integration enhances the functionality of a particular runtime, such as the BrowserTracing integration for the browser runtime or the RequestData integration for the Node.js.js runtime, you can only include these integrations in their respective configuration files:
- For the browser runtime, add integrations to
instrumentation-client.(js|ts). - For Node.js.js, add integrations to your Sentry setup in
instrumentation.(js|ts). - For the Edge runtime, add integrations to your Sentry setup in
instrumentation.(js|ts).
| Auto Enabled | Errors | Tracing | Additional Context | |
|---|---|---|---|---|
dedupeIntegration | ✓ | ✓ | ||
functionToStringIntegration | ✓ | |||
inboundFiltersIntegration | ✓ | ✓ | ||
linkedErrorsIntegration | ✓ | ✓ | ||
captureConsoleIntegration | ✓ | |||
extraErrorDataIntegration | ✓ | |||
rewriteFramesIntegration | ✓ |
| Auto Enabled | Errors | Tracing | Additional Context | |
|---|---|---|---|---|
requestDataIntegration | ✓ | ✓ |
| Auto Enabled | Errors | Tracing | Additional Context | |
|---|---|---|---|---|
winterCGFetchIntegration | ✓ | ✓ | ✓ | |
vercelAiIntegration | ✓ |
To disable system integrations, set defaultIntegrations: false when calling init().
To override their settings, provide a new instance with your config to the integrations option. For example, to turn off browser capturing console calls:
Sentry.init({ dsn: "___PUBLIC_DSN___",
integrations: [ Sentry.breadcrumbsIntegration({ console: false, }), ],
});You can add additional integrations in your init call:
import * as Sentry from "@sentry/browser";
Sentry.init({ dsn: "___PUBLIC_DSN___", integrations: [Sentry.reportingObserverIntegration()],});Alternatively, you can add integrations via Sentry.addIntegration(). This is useful if you only want to enable an integration in a specific environment or if you want to load an integration later. For all other cases, we recommend you use the integrations option.
import * as Sentry from "@sentry/browser";
Sentry.init({ integrations: [],});
Sentry.addIntegration(Sentry.reportingObserverIntegration());Lazy-loading lets you add pluggable integrations without increasing the initial bundle size. You can do this in two ways:
You can add the integration with a dynamic import using import(). This method loads the integration from the npm package. To avoid running into issues with import(), you should use a bundler that supports dynamic imports. If you’re using a tool like Vite for your project, the bundling process is probably already set up.
instrumentation-client.ts
Sentry.init({ // Note, Replay is NOT instantiated below: integrations: [],});Then, somewhere in your application, for example in a useEffect hook, you can lazy-load the Replay integration:
import("@sentry/nextjs").then((lazyLoadedSentry) => { Sentry.addIntegration(lazyLoadedSentry.replayIntegration());});You can also lazy-load pluggable integrations via Sentry.lazyLoadIntegration(). This will attempt to load the integration from the Sentry CDN. Note that this function will reject if it fails to load the integration from the Sentry CDN, which can happen if a user has an ad-blocker or if there’s a network problem. You should always make sure that rejections are handled for this function in your application.
async function loadHttpClient() { const httpClientIntegration = await Sentry.lazyLoadIntegration( "httpClientIntegration", ); Sentry.addIntegration(httpClientIntegration());}Lazy loading is available for the following integrations:
replayIntegrationreplayCanvasIntegrationfeedbackIntegrationfeedbackModalIntegrationfeedbackScreenshotIntegrationcaptureConsoleIntegrationcontextLinesIntegrationlinkedErrorsIntegrationdedupeIntegrationextraErrorDataIntegrationhttpClientIntegrationreportingObserverIntegrationrewriteFramesIntegrationbrowserProfilingIntegration
If you only want to remove a single or some of the default integrations, instead of disabling all of them with defaultIntegrations: false, you can use the following syntax to filter out the ones you don’t want.
This example removes the integration for adding breadcrumbs to the event, which is enabled by default:
Sentry.init({ // ... integrations: function (integrations) { // integrations will be all default integrations return integrations.filter(function (integration) { return integration.name !== "Breadcrumbs"; }); },});You can also create custom integrations.
-
Adds data from incoming requests to transaction and error events that occur during request handling done by the backend. (default)
-
Adds instrumentation for Amqplib. (default)
-
Capture events when the event loop is blocked and the application is no longer responding.
-
Adds instrumentation for the Anthropic SDK.
-
Wraps native browser APIs to capture breadcrumbs. (default)
-
Wraps native time and events APIs (`setTimeout`, `setInterval`, `requestAnimationFrame`, `addEventListener/removeEventListener`) in `try/catch` blocks to handle async exceptions. (default)
-
Capture profiling data for the Browser.
-
Track healthy Sessions in the Browser.
-
Capture performance data for the Browser.
-
Captures all Console API calls via `captureException` or `captureMessage`.
-
Adds instrumentation for child processes and worker threads (default)
-
Capture console logs as breadcrumbs. (default)
-
Capture context about the environment and the device that the client is running on, and add it to events. (default)
-
Adds source code from inline JavaScript of the current page’s HTML.
-
Adds instrumentation for Dataloader.
-
Deduplicate certain events to avoid receiving duplicate errors. (default)
-
Monitor for blocked event loops in all threads of a Node.js application.
-
Extracts all non-native attributes from the error object and attaches them to the event as extra data.
-
Adds instrumentation for filesystem operations.
-
Allows the SDK to provide original functions and method names, even when those functions or methods are wrapped by our error or breadcrumb handlers. (default)
-
Generic Feature Flags Integration
Learn how to attach custom feature flag data to Sentry error events.
-
Adds instrumentation for Generic Pool. (default)
-
Attaches global handlers to capture uncaught exceptions and unhandled rejections. (default)
-
Adds instrumentation for Google Gen AI SDK.
-
Adds instrumentation for GraphQL. (default)
-
Enhance spans and breadcrumbs with data from GraphQL requests.
-
Capture spans & breadcrumbs for http requests. (default)
-
Captures errors on failed requests from Fetch and XHR and attaches request and response information.
-
Attaches HTTP request information, such as URL, user-agent, referrer, and other headers to the event. (default)
-
Allows you to ignore specific errors based on the type, message, or URLs in a given exception. (default)
-
Adds instrumentation for KafkaJS. (default)
-
Adds instrumentation for Knex.
-
Adds instrumentation for LangChain.
-
Adds instrumentation for the LangGraph SDK.
-
Learn how to use Sentry with LaunchDarkly.
-
Allows you to configure linked errors. (default)
-
Add local variables to exception frames. (default)
-
Adds instrumentation for LRU Memoizer. (default)
-
Adds module metadata to stack frames.
-
Add node modules / packages to the event. (default)
-
Adds instrumentation for MongoDB. (default)
-
Adds instrumentation for Mongoose. (default)
-
Adds instrumentation for MySQL. (default)
-
Adds instrumentation for MySQL2. (default)
-
Capture spans & breadcrumbs for node fetch requests. (default)
-
Capture profiling data for Node.js applications.
-
Registers handlers to capture global uncaught exceptions. (default)
-
Registers handlers to capture global unhandled promise rejections. (default)
-
Adds instrumentation for the OpenAI SDK.
-
Learn how to use Sentry with OpenFeature.
-
Capture logs and errors from Pino.
-
Adds instrumentation for Postgres. (default)
-
Adds instrumentation for Prisma. (default)
-
Adds instrumentation for Redis. (default)
-
Capture a video-like reproduction of what was happening in the user’s browser.
-
Capture session replays from HTML canvas elements.
-
Captures the reports collected via the `ReportingObserver` interface and sends them to Sentry.
-
Allows you to apply a transformation to each frame of the stack trace.
-
Learn how to use Sentry with Statsig.
-
Adds instrumentation for Supabase client operations.
-
Adds instrumentation for Tedious. (default)
-
Capture spans & errors for tRPC handlers.
-
Learn how to use Sentry with Unleash.
-
Adds instrumentation for Vercel AI SDK.
-
Connect Web Workers with the SDK running on the main thread
-
Creates spans and attaches tracing headers to fetch requests on edge runtimes. (default)
-
Adds additional data to Zod validation errors.
Pages in this section
Section titled “Pages in this section”- RequestData
- Amqplib
- Anr
- Anthropic
- Breadcrumbs
- BrowserApiErrors
- BrowserProfiling
- BrowserSession
- BrowserTracing
- CaptureConsole
- Child Process Integration
- Console
- Context
- ContextLines
- Dataloader
- Dedupe
- Event Loop Block
- ExtraErrorData
- FileSystem
- FunctionToString
- Generic Feature Flags Integration
- Generic Pool
- GlobalHandlers
- Google Gen AI
- GraphQL
- GraphQLClient
- Http
- HttpClient
- HttpContext
- InboundFilters
- Kafka
- Knex
- LangChain
- LangGraph
- LaunchDarkly
- LinkedErrors
- LocalVariables
- LRU Memoizer
- ModuleMetadata
- Modules
- MongoDB
- Mongoose
- MySQL
- MySQL2
- NodeFetch
- NodeProfiling
- OnUncaughtException
- OnUnhandledRejection
- OpenAI
- OpenFeature
- Pino
- Postgres
- Prisma
- Prisma
- Redis
- Replay
- ReplayCanvas
- ReportingObserver
- RewriteFrames
- Statsig
- Supabase
- Tedious
- trpcMiddleware
- Unleash
- Vercel AI
- WebWorker
- WinterCGFetch
- ZodErrors
- Custom Integrations