[Turbopack] [Pages] Hydration error (or double render) when using dynamic imports in _app.tsx
Open
Nobody has claimed this yet.
linear: turbopack
Module Resolution
Pages Router
Turbopack
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
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/A
Which 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(latest at the time of writing) - 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: https://github.com/vercel/next.js/issues/77712
- and also this one where @gurkerl83 reported it's fixed in
15.1.1-canary.14, though it apparently broke something: https://github.com/vercel/next.js/issues/70795#issuecomment-2555971126- 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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction: run pnpm i, pnpm dev, and compare the root page with /works. Inspect the dynamic import in _app.tsx and the related Pages Router behavior; done means the root page has no hydration errors or duplicate rendering while /works continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react, typescript
- Domain
- build-system, frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100