Skip to content

feat(nextjs): Register nextjs route provider - #23552

Open
logaretm wants to merge 6 commits into
awad/route-provider-apifrom
awad/route-provider-nextjs
Open

logaretm wants to merge 6 commits into
awad/route-provider-apifrom
awad/route-provider-nextjs

Conversation

@logaretm

@logaretm logaretm commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Registers a route provider for Next.js from the manifests already injected at build time, covering both the App Router and the Pages Router.

Registered from init() rather than from browserTracingIntegration, which is the point of the change: both manifests are on the global object before Sentry.init runs, so nothing has to wait for a router or for tracing. bfcacheMetricsIntegration now resolves a parameterized route with browserTracingIntegration absent entirely, and the same will hold for web vitals and interactions as they move over.

The two manifests want the pathname differently, since App Router routes are generated with basePath baked in while Next strips it internally for the Pages Router, so the provider normalizes per manifest.

Part of #23556

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.16 kB +0.02% +9 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 51.18 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Profiling) 54.19 kB +0.02% +9 B 🔺
@sentry/browser (incl. Tracing, Replay) 90.77 kB +0.01% +8 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.87 kB +0.02% +9 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 95.47 kB +0.01% +7 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 108.42 kB +0.01% +8 B 🔺
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31 kB - -
@sentry/react (incl. Tracing) 53.46 kB +0.03% +11 B 🔺
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.71 kB +0.02% +10 B 🔺
@sentry/svelte 29.26 kB - -
CDN Bundle 30.93 kB - -
CDN Bundle (incl. Tracing) 51.7 kB +0.03% +12 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.2 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.67 kB +0.03% +11 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.92 kB - -
CDN Bundle (incl. Tracing, Replay) 89.29 kB +0.02% +9 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.25 kB +0.01% +9 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 95.46 kB +0.02% +11 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.43 kB +0.02% +12 B 🔺
CDN Bundle - uncompressed 91.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 153.81 kB +0.03% +41 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.77 kB +0.03% +41 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.54 kB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.48 kB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.25 kB +0.02% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.17 kB +0.02% +41 B 🔺
@sentry/nextjs (client) 56.03 kB +0.46% +254 B 🔺
@sentry/sveltekit (client) 51.6 kB +0.02% +9 B 🔺
@sentry/core/server 39.96 kB +0.03% +11 B 🔺
@sentry/core/browser 13.63 kB - -
@sentry/node 133.91 kB +0.02% +16 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.43 kB - -
@sentry/node - without tracing 90.47 kB +0.04% +28 B 🔺
@sentry/node - without channel injection 112.42 kB +0.02% +20 B 🔺
@sentry/aws-serverless 98.72 kB +0.02% +13 B 🔺
@sentry/cloudflare (withSentry) - minified 206.53 kB +0.03% +49 B 🔺
@sentry/cloudflare (withSentry) 513.8 kB +0.02% +70 B 🔺

View base workflow run

@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch 2 times, most recently from 737c9cf to 5d8e20b Compare August 24, 2026 20:17
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from 5d8e20b to 464c7d0 Compare August 24, 2026 20:52
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from 464c7d0 to 1eb7910 Compare August 24, 2026 20:57
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch 2 times, most recently from 21288e6 to fec1a68 Compare August 31, 2026 17:05
@logaretm
logaretm changed the base branch from awad/route-provider-api to awad/route-provider-tracing-naming August 31, 2026 17:13
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from fec1a68 to 7016bab Compare August 31, 2026 18:19
@logaretm
logaretm changed the base branch from awad/route-provider-tracing-naming to awad/route-provider-api August 31, 2026 18:19
@logaretm logaretm changed the title feat(nextjs): Register a route provider from the build-time route manifest feat(nextjs): Register a route provider outside the tracing integration Aug 31, 2026
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from 7016bab to fb24bbd Compare August 31, 2026 18:28
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you apply the label PR: no-auto-close I will leave it alone ... forever!

@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch 3 times, most recently from 38c792e to dff53f6 Compare September 24, 2026 18:14
@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch 3 times, most recently from 6727c7a to 13a1451 Compare September 24, 2026 19:11
@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

Both routers already ship a pure matcher: the App Router has the build-time
route manifest behind `maybeParameterizeRoute`, and the Pages Router matches
against `__BUILD_MANIFEST.sortedPages`. Neither was reachable from anywhere
except the pageload and navigation instrumentation.

Registered from `init()` rather than `browserTracingIntegration`, because both
manifests are on the global object before `Sentry.init` runs. Route
parameterization no longer depends on tracing being enabled, so `bfcacheMetrics`
resolves a parameterized route with `browserTracingIntegration` absent.

The two manifests want the pathname differently, since App Router routes are
generated with `basePath` baked in while Next strips it internally for the Pages
Router, so the provider normalizes per manifest.
…named

The provider was registered after `reactInit` returned, but the pageload span is
named in `browserTracingIntegration`'s `afterAllSetup`, which runs inside it. So
every App Router pageload lost its parameterized name.

Registering it from a default integration's `setup` runs it before any
`afterAllSetup` while still not depending on tracing.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@logaretm
logaretm force-pushed the awad/route-provider-nextjs branch from 13a1451 to d20fbbe Compare September 24, 2026 19:59
@logaretm logaretm changed the title feat(nextjs): Register a route provider outside the tracing integration feat(nextjs): Register nextjs route provider Sep 24, 2026
@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d20fbbe. Configure here.

@logaretm
logaretm marked this pull request as ready for review September 24, 2026 21:03
@logaretm
logaretm requested a review from a team as a code owner September 24, 2026 21:03
@logaretm
logaretm requested review from chargome and nicohrubec and removed request for a team September 24, 2026 21:03

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant