You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
script and link tags are not deduplicated (compared to react-helmet-async) #666
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:
In CSR
In SSR
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):
Thanks for the detailed issue. So Unhead out of the box is meant to dedupe any identical tags (unless a key is provided). It seems like there's a SSR bug in that it doesn't check this logic within the tag render group, so for SSR shell, you run into the issue you've outlined.
Activity
fix(unhead): deduplicate `script[src]` and `link[href]` tags across e…
fix(unhead): deduplicate `script[src]` and `link[href]` tags across e…
fix(unhead): deduplicate `script[src]` and `link[href]` tags across e…
fix(unhead): deduplicate `script[src]` and `link[href]` tags across e…
harlan-zw commentedon Feb 25, 2026
Thanks for the detailed issue. So Unhead out of the box is meant to dedupe any identical tags (unless a
keyis provided). It seems like there's a SSR bug in that it doesn't check this logic within the tag render group, so for SSR shell, you run into the issue you've outlined.It should be fixed in v2.1.7 https://stackblitz.com/edit/github-5hqsxyid-2tmhihxq?file=package.json
fix(unhead): deduplicate matching tags inside same render cycle
adbayb commentedon Feb 25, 2026
Thank you @harlan-zw, it works like a charm 👍 .