Skip to content

Start hydration issue with localized head meta title using Lingui i18n #4279

Open
@longzheng

Description

@longzheng

Which project does this relate to?

Start

Describe the bug

When using the Lingui i18n localization + TanStack Start template, when trying to use a localized meta title the page hydrates weirdly.

import { i18n } from "@lingui/core";
import { msg } from "@lingui/core/macro";

export const Route = createFileRoute("/")({
  component: Home,
  head: () => {
    return {
      meta: [
        {
          title: i18n._(msg`Test English title`),
        },
      ],
    };
  },
});

Before hydration, the SSR render is all correct. The page title is localized and the content is correct.

After hydration, the contents appears twice, the top appears to be the SSR version (clicking links will load pages), the bottom appears to be the hydrated client (clicking links do not load pages). The localized title also does not work because there are two <title> in the HTML

<head>
   <title>TanStack Start | Type-Safe, Client-First, Full-Stack React Framework</title>
   <title>Test English title</title>

There are also no hydration errors in the console.

Your Example Website or App

https://codesandbox.io/p/devbox/nice-snowflake-yrx273?file=%2Fsrc%2Froutes%2Findex.tsx%3A3%2C1-4%2C42&workspaceId=ws_62aAsWkSzvrQC9UJ9wAyfv

Steps to Reproduce the Bug or Issue

  1. Go to the sandbox
  2. Open the preview in a new window (to see the page title)
  3. Iinitially the page title will be correct in the SSR version
  4. Wait a few seconds for the client hydration
  5. Page title will be incorrect and content will be doubled

Expected behavior

The page to be hydrated correctly, no double up.
The page title to be localized.

Screenshots or Videos

SSR before hydration

Image

After hydration

Image

Platform

  • OS: Windows
  • Browser: Chrome
  • Version: 137

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