Skip to content

Duplicated <meta> tags when hydration locale differs from SSG locale #6078

@davidavz

Description

@davidavz

Which project does this relate to?

Router

Describe the bug

Hi there 👋
Has anyone hit duplicated tags with TanStack Router head management when the hydration locale differs from the SSG locale?

Context: SSG renders meta tags in FR, on the client, i18n picks EN. <title> updates fine, but meta tags stay in FR and new EN metas are appended, so I end up with two of each. Looking at HeadContent source code, keys are generated from JSON.stringify(tag), which includes the meta content. That means React can’t reconcile the server meta with the client meta if content changes (different language), so it mounts a second node.

Has anyone solved this without hacks (like deleting prerendered metas on load)? Should HeadContent key metas by tag+name/property instead of stringify so hydration can reuse and update them? Happy to open an issue/PR if that’s the right direction.

Your Example Website or App

https://github.com/davidavz/start-basic-static

Steps to Reproduce the Bug or Issue

Run pnpm build + pnpm preview

Expected behavior

Check the DOM and you will see duplicated meta tags FR + EN

Screenshots or Videos

No response

Platform

  • Router / Start Version: ^1.139.13

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions