Skip to content

✨ NextJS Pages Router Integration#4290

Open
BeltranBulbarellaDD wants to merge 10 commits intomainfrom
beltran.bulbarella/NextJS-pagesRouterIntegration
Open

✨ NextJS Pages Router Integration#4290
BeltranBulbarellaDD wants to merge 10 commits intomainfrom
beltran.bulbarella/NextJS-pagesRouterIntegration

Conversation

@BeltranBulbarellaDD
Copy link
Contributor

@BeltranBulbarellaDD BeltranBulbarellaDD commented Mar 7, 2026

Motivation

Adds NextJS Pages Router support to @datadog/browser-rum-nextjs, complementing the existing App Router integration.
Small one pager on the implementation

Changes

Package (packages/rum-nextjs/)

  • DatadogPagesRouter — Client component that starts RUM views on route changes, using useRouter().pathname from next/router which already provides the normalized route pattern (e.g. /user/[id], /guides/[...slug]).
  • Updated README with Pages Router usage instructions alongside existing App Router docs.

E2E infrastructure

  • Adds a Next.js Pages Router test app (test/apps/nextjs-pages-router/) with dynamic routes (/user/[id], /guides/[...slug])
  • Configures the E2E framework to build and serve the Pages Router app alongside existing test apps
  • Adds withNextjsPagesApp() test builder method for Pages Router-specific E2E scenarios

E2E tests

Same as for App Router:

  • Initial view tracking with correct loading_type
  • SPA navigation with loading_time measurement
  • Route normalization across dynamic and catch-all routes, with URL and referrer assertions

Test instructions

  • Existing unit tests in rum-nextjs should pass: yarn test:unit --spec packages/rum-nextjs/src/domain/nextjsPlugin.spec.ts
    • Typecheck should pass: yarn typecheck
    • New E2E tests should pass: yarn test:e2e -g "pages router"

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@BeltranBulbarellaDD BeltranBulbarellaDD changed the title Add .rum-ai-toolkit/ to gitignore ✨ NextJS Pages Router Integration Mar 7, 2026
@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Mar 7, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 174.43 KiB 174.43 KiB 0 B 0.00%
Rum Profiler 6.16 KiB 6.16 KiB 0 B 0.00%
Rum Recorder 25.24 KiB 25.24 KiB 0 B 0.00%
Logs 56.84 KiB 56.84 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 130.11 KiB 130.11 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance

Pending...

🧠 Memory Performance

Pending...

🔗 RealWorld

@datadog-datadog-prod-us1-2
Copy link

datadog-datadog-prod-us1-2 bot commented Mar 7, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 76.76% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 11afd17 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@BeltranBulbarellaDD
Copy link
Contributor Author

@codex pls review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed231d8b5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BeltranBulbarellaDD BeltranBulbarellaDD marked this pull request as ready for review March 9, 2026 08:17
@BeltranBulbarellaDD BeltranBulbarellaDD requested review from a team as code owners March 9, 2026 08:17
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a3bb4f6cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@mormubis mormubis left a comment

Choose a reason for hiding this comment

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

The Pages Router section doesn't mention that instrumentation-client.js requires Next.js v15.3+. Easy to miss if someone jumps straight to the Pages Router section.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants