Skip to content

Update to Next.js 16.2 and React 19.2#8367

Draft
lukesandberg wants to merge 1 commit intoreactjs:mainfrom
lukesandberg:lukesandberg/update_next_16
Draft

Update to Next.js 16.2 and React 19.2#8367
lukesandberg wants to merge 1 commit intoreactjs:mainfrom
lukesandberg:lukesandberg/update_next_16

Conversation

@lukesandberg
Copy link

@lukesandberg lukesandberg commented Mar 20, 2026

Summary

  • Upgrade Next.js from 15.1.11 to 16.2.0 (Turbopack)
  • Upgrade React from 19.0 to 19.2.4
  • Upgrade Prettier to 3.8.1 (required to support import attributes)
  • Migrate ESLint config from legacy .eslintrc to flat config (eslint.config.mjs) for ESLint 9
  • Migrate next.config.js to compatible turbopack configuration
  • Fix Turbopack NFT tracing warning in /api/md/[...path] route by restructuring file reads to be statically analyzable, should reduce deployment size
  • Use with { type: "text" } imports instead of the webpack raw-loader
  • Fix unused variable lint errors and add caughtErrorsIgnorePattern to eslint config
  • Downgrade new react-hooks/set-state-in-effect and react-hooks/refs rules to warnings (pre-existing patterns)
  • Rebuild RSC worker bundle for updated React/RSDW versions
  • Update Icon components and styles for Prettier 3.8 formatting changes

Bundle Analysis

To check actual deltas i fetched a few pages across each version

Route Main (Next 15, webpack) Branch (Next 16, Turbopack) Delta % Change
/ 271,842 B gzip 252,953 B gzip -18,889 B -6.9%
/reference/react/useState 271,842 B gzip 252,953 B gzip -18,889 B -6.9%
/404 269,321 B gzip 250,635 B gzip -18,686 B -6.9%
/llms.txt 0 B 0 B 0 B

The bundle analysis CI action will report a ~12KB/page regression, but this is a measurement artifact: Turbopack populates build-manifest.json differently than webpack, placing shared framework chunks in per-route entries rather than in /_app. The action subtracts /_app chunks as the shared baseline, so these misattributed chunks get counted as page-specific JS. Actual browser-downloaded JS decreased ~7%.

Going forward the per-PRs deltas will be accurate, but for this PR they are not.

Test plan

  • yarn tsc passes
  • yarn lint passes (0 errors)
  • yarn build succeeds with no warnings
  • Production server serves pages correctly (homepage, /learn, /reference, /blog, /community, /llms.txt, /api/md/... all return 200)

🤖 Generated with Claude Code

@meta-cla
Copy link

meta-cla bot commented Mar 20, 2026

Hi @lukesandberg!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions
Copy link

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 122.77 KB (🟢 7.63 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Seven Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 139.4 KB (🟢 12.38 KB) 262.17 KB
/500 139.41 KB (🟢 12.39 KB) 262.18 KB
/[[...markdownPath]] 141.66 KB (🟢 12.2 KB) 264.43 KB
/_error 12.22 KB (🟢 12.04 KB) 134.99 KB
/errors 139.6 KB (🟢 12.33 KB) 262.37 KB
/errors/[errorCode] 139.59 KB (🟢 12.34 KB) 262.36 KB
/llms.txt 10.51 KB (🟢 10.26 KB) 133.28 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by undefined% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@meta-cla
Copy link

meta-cla bot commented Mar 20, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Mar 20, 2026
@MaxwellCohen
Copy link

Thank you for doing this! Looking at this MR and #8338 can be a great comparison of app router vs. pages router in terms of performance for content sites that do not have manual lazy-loading content components (i.e., all the custom markdown components). Doing the same performance I did with app router. Doing some quick performance testing on the useActionState page (this pr build on my machine vs react.dev)

There appears to be no performance downgrade in LCP or INP (good news).

I am still seeing some extra JS being downloaded in this MR vs. prod (2.3 MB on local vs. 1.9 MB in prod). With about 980 KB being used on both sites. Looking at both migrations to turbopack MRs, there appear to be some issues with tree shaking/bundling deoptimization compared to Webpack or next.js 16 requries more JS than next.js 15. I am concerned that I am missing something.

localhost JS coverage report from Chrome
image

Production JS coverage report from Chrome
image

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.

2 participants