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

[App Router] Critical Layout CSS Lacks Preload Link Hints In Document Head

Next.js App Router does not emit `<link rel="preload" as="style">` hints before blocking stylesheets in the initial HTML, forcing the browser preload scanner to wait until the parser encounters each `<link rel="stylesheet">`, which delays FCP.

highConfidence 85%Next.jsAffected V16.4.0-Canary.32

Origin Analysis

The server-rendering CSS resource helper (`renderStylesheetLink`) only outputs a `<link rel="stylesheet">` tag and omits the companion preload hint. Without the preload hint, the browser's speculative parser cannot start downloading critical layout CSS early, serializing stylesheet fetches with DOM parsing and delaying render-blocking resolution.
1. Create an App Router layout with a global stylesheet import. 2. Run `next build && next start`. 3. Inspect the initial HTML `<head>` and observe only `<link rel="stylesheet">` without preceding `<link rel="preload" as="style">`.

Fixing Code Block

Edge Case Audit

The preload link may duplicate a manually injected preload for the same href; ensure deduplication if users add their own `<link rel="preload">` via `next/head` or a custom document. For cross-origin stylesheets (e.g., CDN), a `crossOrigin` attribute must be added to the preload, otherwise the preload is ignored. This change relies on React 19's `precedence` support for preload links; on older React versions the prop may be dropped or warned, so pin `react >= 19.3.0`. If regression occurs, rollback by removing the preload link and restoring the single stylesheet output, ideally behind an environment flag such as `__NEXT_EXPERIMENTAL_CSS_PRELOAD_LINKS`.

Ecosystem Topology