AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Regression: Next/Dynamic Conditionally Importing Client Components Adds Both To Client Bundle In Next.Js 15

Next.js 15 preloads all dynamic imports inside client components, causing both conditional chunks to be sent to the client, increasing initial JavaScript size and TBT compared to Next.js 14. The issue requires a user-land workaround until an upstream fix is released.

highConfidence 75%Next.jsAffected V15.3.3

Origin Analysis

Introduced in Next.js 15, likely by PR #65486, the client-side preload logic for next/dynamic now eagerly preloads all dynamic chunks referenced by a client component, even when they are conditionally rendered. In Next.js 14, only the chunk for the actually rendered component was requested.
Create a Next.js 15.3.3 app with two client components ClientA and ClientB. Use next/dynamic to import them conditionally inside a client component. Render only one based on state. Build and analyze the client bundle: both chunks are included initially, whereas Next.js 14 only includes the rendered chunk.

Fixing Code Block

Edge Case Audit

This workaround disables server-side rendering for the dynamic components. If the components rely on SSR for SEO or initial content, they will show a fallback on the server and may cause layout shift. Also ensure all imports are client components ('use client') to avoid server/client mismatch. Rollback: once Next.js provides an official fix, replace React.lazy with next/dynamic to restore SSR. Test with ssr:false first in a staging environment before deploying, and monitor for hydration errors.

Ecosystem Topology