Skip to content

Update Next.js Build Options with content from Manual Setup page #12852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,47 @@ Automatically instrument components in the `app` directory with error monitoring

</SdkOption>

<SdkOption name="excludeServerRoutes" type="Array<RegExp | string>">
Exclude specific server-side API routes or pages from automatic Sentry instrumentation during build time.
This option takes an array of strings or regular expressions and affects pages in the `pages` and `app` directories.

When defining routes, note the following:

- Specify pages as routes and not as file system paths. For example, write `/animals` instead of `pages/animals/index.js`.
- Make sure that any provided string matches the route exactly, has a leading slash, and doesn't have a trailing slash.

```javascript
excludeServerRoutes: [
"/some/excluded/route",
"/excluded/route/with/[parameter]",
/^\/route\/beginning\/with\/some\/prefix/,
/\/routeContainingASpecificPathSegment\/?/,
];
```

<Alert level="info">
If you're building your Next.js application with Turbopack, this option will
have no effect. The Sentry SDK will no longer apply build-time instrumentation
and will rely purely on Next.js telemetry features.
</Alert>

</SdkOption>

<SdkOption name="tunnelRoute" type="string">
<Alert level="info">
This feature requires **Next.js version 11+** and doesn't currently work with self-hosted Sentry instances.
</Alert>

Tunnel Sentry requests through this route on your Next.js server to prevent ad-blockers from blocking Sentry events from being sent.
This route should be a path, like `/error-monitoring`, as it adds an API endpoint within your application.

Tunnel Sentry requests through this route on the Next.js server, to circumvent ad-blockers blocking Sentry events from being sent. This option should be a path (for example: '/error-monitoring').
Learn more about tunneling in the <PlatformLink to="/troubleshooting/#dealing-with-ad-blockers">troubleshooting section</PlatformLink>.

Note: This feature only works with Next.js 11+
<Expandable level="warning" title="Complications with Next.js middleware">
Client-side event recording will fail if your Next.js middleware intercepts
the configured route. To prevent this, exclude the tunnel route by adding a
negative matcher to your middleware like `(?!monitoring-tunnel)`.
</Expandable>

</SdkOption>

Expand All @@ -195,3 +231,18 @@ Note: This feature only works with Next.js 11+
Automatically create cron monitors in Sentry for your Vercel Cron Jobs if configured via `vercel.json`.

</SdkOption>

<SdkOption
name="unstable_sentryWebpackPluginOptions"
type="SentryWebpackPluginOptions"
>
Pass configuration options directly to the [Sentry Webpack
Plugin](https://www.npmjs.com/package/@sentry/webpack-plugin) that ships with
the Sentry Next.js SDK. If `withSentryConfig` doesn't provide the option you
need to modify, you may override the `sentryWebpackPluginOptions` using this
option.
<Alert level="warning" title="Important">
This option is considered unstable, and its API may change in a breaking way
in any release.
</Alert>
</SdkOption>