Skip to content

Conversation

@Meldiron
Copy link
Contributor

@Meldiron Meldiron commented Oct 27, 2025

In next.js 16 they removed _app.js we used to use for detection.

I now use same files as in Open Runtimes: https://github.com/open-runtimes/open-runtimes/blob/e9d2ba04ebc1c414acb551355cbeff904f0c326b/runtimes/node/versions/latest/helpers/next-js/bundle.sh#L10-L11

If this breaks in future, I will involve Next.js team to help us find futureproof solution. But this should be good and solid for now.

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection accuracy for Next.js SSR builds by updating identification logic to better recognize turbopack and webpack runtime layouts.
  • Tests
    • Expanded unit test coverage with additional Next.js scenarios to validate static and SSR detection across more file-set combinations.

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

The pull request updates Next.js SSR detection: the framework mapping now recognizes .next/server/webpack-runtime.js and .next/turbopack instead of .next/server/pages/_app.js to identify Next.js server-side rendering builds. Unit tests were updated and expanded to reflect the new detection patterns, including adjustments to an existing expectation and the addition of new test cases covering the new detection files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review changes in src/Detection/Rendering/SSR.php to confirm the new file indicators are correct and sufficient.
  • Verify tests in tests/unit/DetectorTest.php align with the updated detection logic and cover relevant static vs. SSR cases.
  • Check for any other places where Next.js detection assumptions might need updates (e.g., other tests or mappings).

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Fix: Next.js 16 ssr detection" accurately reflects the main objective of the changeset. According to the PR description, the changes address the removal of _app.js in Next.js 16 by updating detection methods to use .next/server/webpack-runtime.js and .next/turbopack instead. The title clearly identifies this as a fix for Next.js 16 SSR detection, which is exactly what the modifications in SSR.php and the corresponding test updates accomplish. The title is specific and meaningful enough that a teammate reviewing the commit history would immediately understand the primary purpose of these changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-nextjs-detection

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61301f0 and 9b77769.

📒 Files selected for processing (1)
  • tests/unit/DetectorTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/unit/DetectorTest.php

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@hmacr hmacr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/unit/DetectorTest.php (2)

355-357: Add coverage for “.next/turbopack” (non-server layout) or align mapping.

There’s an SSR case for “.next/server/turbopack”, but none for “.next/turbopack”. Either add a test for the non-server path or confirm we won’t support it.

         return [
-            [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/pages/_app.js'], 'nextjs', 'static', null],
-            [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/turbopack'], 'nextjs', 'ssr', null],
-            [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/webpack-runtime.js'], 'nextjs', 'ssr', null],
+            [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/pages/_app.js'], 'nextjs', 'static', null],
+            [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/turbopack'], 'nextjs', 'ssr', null],
+            [['server/pages/index.html', 'server/pages/api/users.js', '.next/server/webpack-runtime.js'], 'nextjs', 'ssr', null],
+            [['server/pages/index.html', 'server/pages/api/users.js', '.next/turbopack'], 'nextjs', 'ssr', null],
         ];

355-355: Confirm intentional drop of legacy Next ≤15 SSR marker.

Changing “.next/server/pages/_app.js” to classify as static will make older Next SSR builds detect as static. OK to drop backward compatibility?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 795ed56 and 61301f0.

📒 Files selected for processing (2)
  • src/Detection/Rendering/SSR.php (1 hunks)
  • tests/unit/DetectorTest.php (1 hunks)

@Meldiron Meldiron merged commit 89f96e8 into main Oct 27, 2025
4 checks passed
@stnguyen90 stnguyen90 mentioned this pull request Dec 4, 2025
2 tasks
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.

2 participants