Component not rendering correctly when using dynamic import in Next.js #78187
-
SummaryHello I'm using dynamic import to load a component in my Next.js app, but it's not rendering properly on the client side. Here’s what I’m doing: const MyComponent = dynamic(() => import('../components/MyComponent'), { ssr: false });
When I load the page, the placeholder flashes briefly and then nothing shows up — no errors in the console either.
I’ve tried:
Making sure the path is correct
Wrapping the component in a client component
Testing with and without { ssr: false }
Still not working. Am I missing something with how dynamic import works in the latest version of Next.js?
Thanks in advance!
### Additional information
```js
Next.js version: 14.1.x
React version: 18
Running on: Windows 11 + Chrome
Rendering mode: App Router (with app/ directory)
No error in terminal or console, but component doesn’t appear on screen ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey , dynamic imports in Next.js with A few things to check:
3 Check for conditional rendering or CSS issues If none of that works, try logging something inside MyComponent to confirm if it’s even being mounted. Let me know what u find |
Beta Was this translation helpful? Give feedback.
Hey , dynamic imports in Next.js with
ssr: false
can be a bit tricky depending on the component u're importing and how it's being used.A few things to check:
Is ur component actually a client component?
If u're using the app directory (
/app
), make sure urMyComponent
file starts with"use client"
— otherwise it won’t run on the client even if u disable SSR.Try wrapping it in a parent client component
Sometimes the dynamic import works only if the parent is also marked as a client component. u can try something like: