Skip to content

Commit b61cf6a

Browse files
docs(nextjs): Update Next.js Build Options with content from Manual Setup page (#12852)
1 parent c64fb08 commit b61cf6a

File tree

1 file changed

+53
-2
lines changed
  • docs/platforms/javascript/guides/nextjs/configuration/build

1 file changed

+53
-2
lines changed

docs/platforms/javascript/guides/nextjs/configuration/build/index.mdx

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,47 @@ Automatically instrument components in the `app` directory with error monitoring
182182

183183
</SdkOption>
184184

185+
<SdkOption name="excludeServerRoutes" type="Array<RegExp | string>">
186+
Exclude specific server-side API routes or pages from automatic Sentry instrumentation during build time.
187+
This option takes an array of strings or regular expressions and affects pages in the `pages` and `app` directories.
188+
189+
When defining routes, note the following:
190+
191+
- Specify pages as routes and not as file system paths. For example, write `/animals` instead of `pages/animals/index.js`.
192+
- Make sure that any provided string matches the route exactly, has a leading slash, and doesn't have a trailing slash.
193+
194+
```javascript
195+
excludeServerRoutes: [
196+
"/some/excluded/route",
197+
"/excluded/route/with/[parameter]",
198+
/^\/route\/beginning\/with\/some\/prefix/,
199+
/\/routeContainingASpecificPathSegment\/?/,
200+
];
201+
```
202+
203+
<Alert level="info">
204+
If you're building your Next.js application with Turbopack, this option will
205+
have no effect. The Sentry SDK will no longer apply build-time instrumentation
206+
and will rely purely on Next.js telemetry features.
207+
</Alert>
208+
209+
</SdkOption>
210+
185211
<SdkOption name="tunnelRoute" type="string">
212+
<Alert level="info">
213+
This feature requires **Next.js version 11+** and doesn't currently work with self-hosted Sentry instances.
214+
</Alert>
215+
216+
Tunnel Sentry requests through this route on your Next.js server to prevent ad-blockers from blocking Sentry events from being sent.
217+
This route should be a path, like `/error-monitoring`, as it adds an API endpoint within your application.
186218

187-
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').
219+
Learn more about tunneling in the <PlatformLink to="/troubleshooting/#dealing-with-ad-blockers">troubleshooting section</PlatformLink>.
188220

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

191227
</SdkOption>
192228

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

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

0 commit comments

Comments
 (0)