vercel / vercel/next.js

Inline page metadata overwritten by layout metadata

Open
#77,681 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Metadata
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and compare the initial page visit with navigation between pages. Trace Next.js metadata handling for React 19's hoisted inline metadata; done means inline page metadata takes priority over layout metadata on direct visits without regressing navigation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.