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

Turbopack Build Omits __NEXT_DATA__.DynamicIds For Next/Dynamic({ Ssr: True }) Declared In Pages/_App — Server HTML Discarded On Hydration

Next.js 16 Turbopack builds fail to include module IDs for ssr:true dynamic components declared in pages/_app.tsx in the __NEXT_DATA__.dynamicIds array. This causes client-side hydration mismatches, discarding server-rendered markup for persistent site chrome (header/footer/cookie banner) and breaking SSR/SEO for those sections.

criticalConfidence 85%Next.jsAffected V16.3.3Affected V16.3.4

Origin Analysis

Turbopack's loadable manifest collection logic does not traverse or merge dynamic import IDs from the pages/_app module during the build, unlike Webpack. The _app module's loadable components are server-rendered but their module IDs are omitted from the dynamicIds serialized into the HTML, causing React to treat them as not yet loaded during hydration and fall back to the loading state, triggering a hydration mismatch.
1. Clone https://github.com/milosz-gustawski/next16-turbopack-app-dynamicids-repro 2. Run `npm install` 3. Run `npm run build` (default Turbopack) and inspect `.next/server/pages/index.html` for `__NEXT_DATA__.dynamicIds` — observe only page-level dynamic ID present, _app-level missing. 4. Run `npm run build:webpack` and repeat inspection — both IDs present. 5. Start the Turbopack build and open browser console: hydration mismatch error and server HTML replaced.

Fixing Code Block

Edge Case Audit

Disabling Turbopack removes its performance benefits (faster builds, faster refresh). It may also limit access to Turbopack-specific features. If Next.js removes Webpack support in a future major version, this workaround will break. Rollback: once the official fix is released, remove the `experimental.turbopack: false` line and retest the application to ensure dynamicIds are restored under Turbopack. For applications already in production with Turbopack, consider deploying the Webpack build until the fix is available.

Ecosystem Topology