Skip to content

Inline page metadata overwritten by layout metadata #77681

@Netail

Description

@Netail

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/repro-next-layout-metadata-hxmpxr

To Reproduce

  1. Have a fallback metadata set in your layout
  2. Set custom inline metadata using React 19's metadata hoisting
  3. Visit the root page directly (the title says "Metadata: Root Layout" instead of "Metadata: Page")
  4. Navigate to test page & back using the link, now the title is correctly set

Current vs. Expected behavior

The inline metadata, which get hoisted by react (since React 19), gets overwritten by the static metadata from the layout.

This only happens on an initial page visit (but impacts SEO), when routing between pages the metadata is correctly set

As the page metadata is lower in the hierarchy that the layout metadata, I would expect to have the page metadata to have priority over the layout metadata

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.12.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.2.4 // Latest available version is detected (15.2.4) 
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Metadata

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    MetadataRelated to Next.js' Metadata API.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions