next/dynamic from external package causes hydration errors for combination of pages and app routers #69125
Labels
bug
Issue was opened via the bug report template.
Lazy Loading
Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`).
Pages Router
Related to Pages Router.
Runtime
Related to Node.js or Edge Runtime with Next.js.
Link to the code that reproduces this issue
https://github.com/adanperez/nextjs-dynamic-hydration-error
To Reproduce
pnpm run build
pnpm run start
You will see the following Hydration errors in the console.
Current vs. Expected behavior
Current
Currently we get hydration errors when using a
next/dynamic
component from an external package.Expected
We do not expect to get hydration errors.
If you remove the
app
directory and rebuild and start the app, you will no longer see hydration errors. The combination ofpages
andapp
directories causes the hydration error.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 20.10.0 npm: 10.2.3 Yarn: N/A pnpm: 9.4.0 Relevant Packages: next: 14.2.5 // Latest available version is detected (14.2.5). eslint-config-next: 14.2.5 react: 18.3.1 react-dom: 18.3.1 typescript: 5.5.4 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Lazy Loading, Pages Router, Runtime
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: