Skip to content

Commit 74f9c36

Browse files
logaretmCopilotinventarSarah
authored
docs(nextjs): document the route manifest injection option (#16076)
This document outlines the new option introduced in getsentry/sentry-javascript#18798, which was released in `10.34.0`. This option replaces the `disableManifestinjection` option, providing users with the flexibility to either completely disable this behavior or selectively exclude specific routes from being included in the route manifest. A common use case for this option is when some routes are private or contain unreleased features. Having these routes present in the route manifest posed challenges for certain users. To address this, an `exclude` option allows users to avoid the all-or-nothing compromise, ensuring that data quality is maintained and preventing the leakage of route information. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Sarah Mischinger <sarah@codingwriter.com>
1 parent ba53daa commit 74f9c36

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

  • docs/platforms/javascript/guides/nextjs/configuration/build

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

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,52 @@ Enables the use of the [`runAfterProductionCompile` hook from Next.js](https://n
222222

223223
</SdkOption>
224224

225-
<SdkOption name="disableManifestInjection" type="boolean|undefined" defaultValue="false">
225+
<SdkOption name="routeManifestInjection" type="boolean|object" defaultValue="true">
226226

227-
Disables automatic injection of the route manifest into the client bundle.
227+
<AvailableSince version="10.34.0" />
228228

229-
The route manifest is a build-time generated mapping of your Next.js App Router routes that enables Sentry to group transactions by parameterized route names (e.g., `/users/:id` instead of `/users/123`, `/users/456`, etc.).
229+
<Alert level="info" title="App Router only">
230+
`routeManifestInjection` option is only supported in the App Router.
231+
</Alert>
232+
233+
Controls injection and filtering of the route manifest in the client bundle.
234+
235+
The route manifest is a build-time generated mapping of your Next.js App Router routes that enables Sentry to group transactions by parameterized route names (for example, `/users/:id` instead of `/users/123` or `/users/456`).
236+
237+
You can set this option to `false` to disable the route manifest injection.
230238

231239
**Disable this option if:**
232240

233241
- You want to minimize client bundle size
234242
- You're experiencing build issues related to route scanning
235243
- You prefer raw URLs in transaction names
236-
- You're only using the Pages Router (this feature is only supported in the App Router)
244+
245+
You can also pass in an object with an `exclude` property to control which routes should be excluded from the route manifest. The `exclude` property accepts an array of strings or regular expressions, or a function that returns `true` to exclude a route.
246+
247+
```javascript
248+
withSentryConfig(nextConfig, {
249+
// Exclude specific routes using an array of strings or RegExps
250+
routeManifestInjection: {
251+
exclude: ["/api/health", "/api/excluded/[parameter]", /^\/internal\//],
252+
},
253+
});
254+
```
255+
256+
```javascript
257+
withSentryConfig(nextConfig, {
258+
// Or use a function for dynamic exclusion
259+
routeManifestInjection: {
260+
exclude: (route) => route.includes("/excluded"),
261+
},
262+
});
263+
```
264+
265+
Excluded routes will appear as raw URLs in transaction names instead of parameterized routes.
266+
267+
**Use `exclude` if:**
268+
269+
- You want to hide internal or unreleased routes from appearing in the client bundle
270+
- You want to reduce bundle size by excluding routes that don't benefit from parameterized grouping (for example, static routes with no dynamic segments)
237271

238272
</SdkOption>
239273

0 commit comments

Comments
 (0)