nextjs - 💡(How to fix) Fix Unable to add `<link rel="preload">` for CSS chunks used on page [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#93153Fetched 2026-04-24 05:50:43
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
issue_type_added ×1

Code Example

<link rel="stylesheet" href="/_next/static/chunks/0bvc3j5yi~l81.css" data-precedence="next">

---

<link rel="preload" href="/_next/static/chunks/0bvc3j5yi~l81.css" as="style">
<link rel="stylesheet" href="/_next/static/chunks/0bvc3j5yi~l81.css" data-precedence="next">

---

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32691
  Available CPU cores: 24
Binaries:
  Node: 25.9.0
  npm: 11.12.1
  Yarn: N/A
  pnpm: 10.33.0
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

in attachments

To Reproduce

css-preload.zip

  1. unzip
  2. build
  3. start
  4. run Lighthouse in devtools
  5. See issues with Network dependency tree related to generated .css

Current vs. Expected behavior

Current:

<link rel="stylesheet" href="/_next/static/chunks/0bvc3j5yi~l81.css" data-precedence="next">

Expected:

<link rel="preload" href="/_next/static/chunks/0bvc3j5yi~l81.css" as="style">
<link rel="stylesheet" href="/_next/static/chunks/0bvc3j5yi~l81.css" data-precedence="next">

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32691
  Available CPU cores: 24
Binaries:
  Node: 25.9.0
  npm: 11.12.1
  Yarn: N/A
  pnpm: 10.33.0
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

CSS

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

This is very simple performance improvement makes happy pagespeed and lighthouse.

This is important when we have multiple CSS files on page.

Reling to this docs (https://nextjs.org/docs/app/api-reference/functions/generate-metadata#link-relpreload), I can insert variuous tags in head, to preload different resources, but I did't found a way how to preload bundled CSS files.

May be is there a way to get CSS chunks for current page and to pass them to generateMetadata?

extent analysis

TL;DR

Investigate using Next.js' generateMetadata function to inject rel="preload" links for CSS chunks.

Guidance

  • Review the Next.js documentation on generateMetadata to understand how to inject custom links into the HTML head.
  • Explore the possibility of accessing CSS chunks for the current page using Next.js APIs or internals.
  • Consider using a custom getStaticProps or getServerSideProps function to generate metadata for each page, including preloading CSS chunks.
  • Investigate if there are any existing plugins or libraries that provide this functionality for Next.js.

Example

No specific code example can be provided without further information on the project's structure and requirements.

Notes

The solution may require a deep understanding of Next.js internals and the project's specific configuration. Additionally, the approach may vary depending on the version of Next.js being used.

Recommendation

Apply a workaround by using the generateMetadata function to inject custom rel="preload" links for CSS chunks, as this seems to be the most promising approach based on the provided documentation and context.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Unable to add `<link rel="preload">` for CSS chunks used on page [1 participants]