Skip to content

Conversation

@SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Oct 13, 2025

@ascorbic Here is another bugfix~

I have some routes under the src/routes folder, and I noticed that there are duplicated <meta /> tags within the generated <head /> from the SSR-ed HTML.

It turns out that although there are many routes, they all share only one singleton head manager class instance (there is only one new HeadContext()). So any heads added in the route A will also be there for route B.

The proper way to do this would be to have one head manager instance for each route, not sharing one head manager across all routes.

The PR changes a few things:

  • Renames class HeadProvider to class HeadManager
    • This avoids name collision and better reflects what this class is actually for
  • In entry-server, wraps <Page /> with a <HeadContext.Provider />
    • Now each page will have its own head manager instance during SSR
    • Then we can use that head manager instance to get each route's own <head />

Breaking Changes

Currently, all routes share one head manager instance, so every HTML generated will contain all routes' heads altogether.

Though this behavior might be buggy, some existing apps might be relying on this behavior.

After the PR, every route will have its own head manager instance, its HTML will only contain its own head, which will break above mentioned apps (if any).

@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for impala-preact-js ready!

Name Link
🔨 Latest commit d3741cd
🔍 Latest deploy log https://app.netlify.com/projects/impala-preact-js/deploys/68ed117d28490f000842eef2
😎 Deploy Preview https://deploy-preview-43--impala-preact-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for impala-react-js ready!

Name Link
🔨 Latest commit d3741cd
🔍 Latest deploy log https://app.netlify.com/projects/impala-react-js/deploys/68ed117d6e139300082cb0c0
😎 Deploy Preview https://deploy-preview-43--impala-react-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for impala-react-ts ready!

Name Link
🔨 Latest commit d3741cd
🔍 Latest deploy log https://app.netlify.com/projects/impala-react-ts/deploys/68ed117d0063a50008852d24
😎 Deploy Preview https://deploy-preview-43--impala-react-ts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for impala-preact-ts ready!

Name Link
🔨 Latest commit d3741cd
🔍 Latest deploy log https://app.netlify.com/projects/impala-preact-ts/deploys/68ed117db8bf1c0008f2cea0
😎 Deploy Preview https://deploy-preview-43--impala-preact-ts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@SukkaW SukkaW marked this pull request as draft October 13, 2025 14:26
@SukkaW SukkaW changed the title fix: add <HeadProvider /> (WIP) fix: add <HeadProvider /> Oct 13, 2025
@SukkaW SukkaW force-pushed the fix-head branch 2 times, most recently from 92ca50f to 8dbdb0a Compare October 13, 2025 14:41
@SukkaW SukkaW changed the title (WIP) fix: add <HeadProvider /> (WIP) fix!: add <HeadProvider /> Oct 13, 2025
@SukkaW SukkaW changed the title (WIP) fix!: add <HeadProvider /> fix!: add <HeadProvider /> Oct 13, 2025
@SukkaW SukkaW marked this pull request as ready for review October 13, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant