nextjs app-dir bug with dynamic imports #43764
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`).
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Dynamic imports (next/dynamic)
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
https://stackblitz.com/edit/nextjs-zkhpkm?file=app%2Ftest%2Fpage.js
To Reproduce
Go to the page
/test
on your browser, you'll see that the console.log which is supposed to only run on client get to run also on the server. You will also see that nextjs show that hydration errors occurs.It seems like the component which is marked with
ssr: false
still get to run on the server and you can even inspect the source code generated and you will see the content of the server .You can check the page at
/problem
which is located in thepages
directory and it seems to work there without an issue.Describe the Bug
Within app directory nextjs seems to ignore the parameter
ssr: false
when using dynamic imports and always run the component on the server. On top of that it produces a hydration error when used.This seems to only occur within the app directory and not the
pages
directory.For information i used the import on pages with the 'use client' directive on top.
Expected Behavior
Nextjs should respect the parameter
ssr: false
of dynamic imports and not try to render the page on the server.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: