Skip to content

script and link tags are not deduplicated (compared to react-helmet-async) #666

@adbayb

Description

@adbayb

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:

  • 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):

Image Image

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions