opennextjs-cloudflare: [BUG] Page router next/head component not working for SSR pages
Describe the bug
When the Page Router next/head component is used on SSG or dynamic (SSR) pages the html that came from the server did not have the meta tags that the component should add.
The meta tags are added later (on hydration phase I suppose), if I inspect the page in the devtools Elements tab I can verify it.
On static pages it works ok.
Steps to reproduce
- Clone this reproduction repo created with the
npm create cloudflare@latest -- my-next-app --framework=next --platform=workerscommand: https://github.com/hcentelles/my-next-app - Install deps:
npm i - Run the app with the “native” nextjs server:
npm run build && npm run start - Download the html of the SSG example page:
curl -o ssg-nextjs.html http://localhost:3000/ssg - Kill the nextjs server Ctrl+C
- Run the app with the opennext preview command:
npm run preview - Download the html of the SSG example page:
curl -o ssg-opennext.html http://localhost:8787/ssg - Compare both files to verify that in
ssg-nextjs.htmlexist the<title data-next-head="">SSG Example</title>tag but inssg-opennext.htmldo not exist.
Expected behavior
I would expect the <title data-next-head="">SSG Example</title> tag to be in ssg-opennext.html too.
@opennextjs/cloudflare version
1.0.0-beta.2
Wrangler version
4.10.0
next info output
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8122
Available memory (MB): 24576
Available CPU cores: 8
Binaries:
Node: 20.12.1
npm: 10.5.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 15.2.5 // There is a newer version (15.3.0) available, upgrade recommended!
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: N/A
Next.js Config:
output: N/A
⚠ There is a newer version (15.3.0) available, upgrade recommended!
Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (3 by maintainers)
Should be in beta-4 now
It’s not in an npm release yet, you can try using https://github.com/opennextjs/opennextjs-cloudflare/pull/607#issuecomment-2834798820
I’ll likely make a patch by the end of the week
As i suspected the issue is that we have multiple context (it’s not in
_documentthough, but inpages-runtime.prod.js. We need to apply a patch similar to what’s done here at build time : https://github.com/vercel/next.js/blob/21d2a32d50164f877917c6c79dfc0e6686a5bb59/packages/next/src/server/require-hook.ts#L60-L67@vicb @conico974 thanks for your answers . Do you think it’s OK to reopen this issue changing the title to reflect it’s related to SSR or should I open a new one?