Environment
Node.js: v24.13.0.
Unhead/react: v2.1.6.
Reproduction
Sandbox: https://stackblitz.com/edit/github-5hqsxyid-da1rkaug?file=src%2FApp.tsx
Describe the bug
I’m migrating from react-helmet-async to @unhead/react and noticed a difference in deduplication behavior.
In @unhead/react, script and link tags with the same attributes (src, href, as, rel) are not deduplicated. However, title and meta (e.g., description) are correctly deduplicated.
With react-helmet-async, identical script and link tags are properly deduplicated (only one instance is injected into the DOM).
The issue reproduces:
Thank you!
Expected behavior
When multiple script or link tags are defined with identical attributes (e.g., src, href, as, rel, async, defer, ...), only a single instance should be rendered in the DOM, similar to the behavior of react-helmet-async.
Actual behavior
Duplicate script and link elements are rendered in the DOM, even when all identifying attributes match.
Additional context
This creates inconsistencies when migrating from react-helmet-async, where deduplication works as expected for these tags.
Here are some screenshots showcasing the actual results (taken from the sandbox):
Logs
Environment
Node.js: v24.13.0.
Unhead/react: v2.1.6.
Reproduction
Sandbox: https://stackblitz.com/edit/github-5hqsxyid-da1rkaug?file=src%2FApp.tsx
Describe the bug
I’m migrating from
react-helmet-asyncto@unhead/reactand noticed a difference in deduplication behavior.In
@unhead/react,scriptandlinktags with the same attributes (src,href,as,rel) are not deduplicated. However,titleandmeta(e.g., description) are correctly deduplicated.With
react-helmet-async, identicalscriptandlinktags are properly deduplicated (only one instance is injected into the DOM).The issue reproduces:
Thank you!
Expected behavior
When multiple
scriptorlinktags are defined with identical attributes (e.g.,src,href,as,rel,async,defer, ...), only a single instance should be rendered in the DOM, similar to the behavior ofreact-helmet-async.Actual behavior
Duplicate
scriptandlinkelements are rendered in the DOM, even when all identifying attributes match.Additional context
This creates inconsistencies when migrating from
react-helmet-async, where deduplication works as expected for these tags.Here are some screenshots showcasing the actual results (taken from the sandbox):
Logs