When using Next.js dynamic imports, carefully evaluate whether to disable server-side rendering (SSR) based on the component's purpose and impact on user experience.
When using Next.js dynamic imports, carefully evaluate whether to disable server-side rendering (SSR) based on the component’s purpose and impact on user experience.
Keep SSR enabled (default) when:
Disable SSR (ssr: false
) when:
Example:
// ❌ Avoid for layout-affecting components
const CloudBanner = dynamic(() => import('@/features/AlertBanner/CloudBanner'), { ssr: false });
// ✅ Good for error handling
export default dynamic(() => import('@/components/Error'), { ssr: false });
// ✅ Consider for modals
const ModalContent = dynamic(() => import('./ModalContent'), { ssr: false });
The key is preventing layout shifts while ensuring functionality works correctly across SSR and client-side rendering.
Enter the URL of a public GitHub repository