-
Couldn't load subscription status.
- Fork 29.7k
Open
Labels
Module ResolutionModule resolution (CJS / ESM, module resolving).Module resolution (CJS / ESM, module resolving).Pages RouterRelated to Pages Router.Related to Pages Router.TurbopackRelated to Turbopack with Next.js.Related to Turbopack with Next.js.
Description
Link to the code that reproduces this issue
https://github.com/rtrembecky/next-turbopack-hydration-repro
To Reproduce
- Install the deps -
pnpm i - Start the app -
pnpm dev - Navigate to http://localhost:3000
Current vs. Expected behavior
Current behavior:
Expected: No errors.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:29 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6000
Available memory (MB): 32768
Available CPU cores: 10
Binaries:
Node: 24.2.0
npm: 11.4.0
Yarn: 1.22.19
pnpm: 9.15.9
Relevant Packages:
next: 16.0.1-canary.2 // Latest available version is detected (16.0.1-canary.2).
eslint-config-next: N/A
react: 19.2.0
react-dom: 19.2.0
typescript: 5.9.3
Next.js Config:
output: N/AWhich area(s) are affected? (Select all that apply)
Pages Router, Module Resolution, Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), Other (Deployed)
Additional context
Pinpointed broken versions:
- canary: >=
15.1.1-canary.14, up to16.0.1-canary.2 - stable: >=
15.2.0
Working versions:
15.1.1-canary.1315.1.6
Background:
_app.tsximports a component vianext/dynamic- this causes a hydration issue- when the same component is imported from the page level as well, it works - http://localhost:3000/works page (in repro repo) works
- when the
<main>wrapper in_app.tsxis removed or replaced by a<>fragment, the dynamic element is rendered TWICE instead- so this issue looks related: next/dynamic not hydrating content and rendering twice on pages dir #77712
- and also this one where @gurkerl83 reported it's fixed in
15.1.1-canary.14, though it apparently broke something: Hydration error when using Turbopack with dynamically imported named exports. #70795 (comment)- cc @timneutkens as you were involved on that one, but I understand it's been quite a while
Real world scenario:
- On www.groupon.com, we use
const Layout = Component.getLayout || DefaultLayout;in_app.tsx, whereDefaultLayoutis imported dynamically - it's not needed for a user that accesses only pages with custom layouts (defined on the page level viaPage.getLayout).- -> We are getting hydration errors in dev when using Turbopack, and also production React minified errors (even though we haven't migrated build to Turbopack yet, so it might be a different issue).
jskorepa-grpn, tans105, xxramonxx, jahilldev, TomasSlama and 1 more
Metadata
Metadata
Assignees
Labels
Module ResolutionModule resolution (CJS / ESM, module resolving).Module resolution (CJS / ESM, module resolving).Pages RouterRelated to Pages Router.Related to Pages Router.TurbopackRelated to Turbopack with Next.js.Related to Turbopack with Next.js.