Replies: 10 comments 5 replies
This comment has been hidden.
This comment has been hidden.
-
the sandbox URL wasn't detected because it was missing |
Beta Was this translation helpful? Give feedback.
-
@stefa98 Thank you for submitting an issue! We are taking a look |
Beta Was this translation helpful? Give feedback.
-
@stefa98 I believe this was always the case (pre v15 stable release). Currently, you need to have PPR (canary only) enabled to see Link Headers in Production. Not sure yet about the behavior in Development where it's showing without PPR enabled, so sharing this with the team! |
Beta Was this translation helpful? Give feedback.
-
#36089 To be honest, I eagerly hope that Next.js can support this feature. The neighboring Nuxt.js (https://nuxt.com/docs/guide/going-further/experimental-features#writeearlyhints) has already supported it for a while. |
Beta Was this translation helpful? Give feedback.
-
Hi @samcx Is there any news. about it? It would be a great thing to implement “Link” Headers for Critical Resources. it is a standard now that is used by so many websites and allows for better performance. Also I don't think it is that complicated to implement, it would be very nice for the next release and besides it is an issue that has been presented for months by the community |
Beta Was this translation helpful? Give feedback.
-
Agreed. All that's needed is a proper HTML format, and something like Cloudflare Pages automatically emits Early Hints: |
Beta Was this translation helpful? Give feedback.
-
The browser can prioritize better when there are link tags present in the page versus the header. When the page is fully static, there's no time advantage to injecting the link headers. It's present in dev all the time because these pages are rendered dynamically each time, though we may be omitting that in future releases to make it more consistent. When Partial Prerendering is enabled (via the Future work may enable the 103 early hints, but we don't have a timeline for that yet. (but stay tuned 🥳!) TLDR; this is working as expected, so we're going to close this for now. I'll move this to a discussion so we can continue to receive feedback on this case. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
In fact, this can also benefit users of the page router, as browsers can preload static resources without waiting for backend API calls to complete. @samcx |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/next-js-15-d55c3c
To Reproduce
Current vs. Expected behavior
Current behavior:
In development mode, the Link header correctly includes critical resources to preload, such as fonts and stylesheets. However, in production or preview (e.g., on Vercel), the Link header is not present, and resources are not preloaded in the same way.
Expected behavior:
The Link header should also be present in production mode, allowing the browser to preload critical resources and potentially enable optimizations like 103 Early Hints.
Provide environment information
Which area(s) are affected? (Select all that apply)
Output (export/standalone), Performance
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Vercel (Deployed)
Additional context
The problem also occurs with the default nextjs template, implemented with “npx create-next-app”
I believe I found the logic that handles critical resources in the Link header in the following file:
next.js/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-server.node.production.js
Line 5723 in 51d6e76
The function safelyEmitEarlyPreloads seems to generate the Link header correctly during rendering, but it doesn't appear to be emitted in production. Is there a new option or configuration that needs to be enabled to have these critical resources included in the Link header during production? This would be particularly useful for enabling 103 Early Hints.
Thank you for any insights!
Beta Was this translation helpful? Give feedback.
All reactions