Skip to content

Pages router: meta element doesn't update on navigation #81689

@eostrom-livefront

Description

@eostrom-livefront

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/sad-pike-2zgvvw

To Reproduce

  1. Start the application in development (next dev)
  2. Go to the home page.
  3. Inspect the page in devtools.
  4. Note that the head for the iframe contains <meta name="description" content="Home metadata">, as declared in the Home component.
  5. Click the link.
  6. Inspect the page in devtools.
  7. Note that the head for the iframe still contains <meta name="description" content="Home metadata">, even though the Destination component declares it with different content (and the same key).
  8. Reload the iframe.
  9. Inspect the page in devtools.
  10. Note that the head for the iframe contains <meta name="description" content="Destination metadata">, as declared in the Destination component.

Current vs. Expected behavior

The meta tag should have the content declared in the current page component.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.4.2-canary.0 // Latest available version is detected (15.4.2-canary.0).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.1.3
Next.js Config:
  output: N/A
Done in 2.06s.

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

Metadata

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

next dev (local)

Additional context

Also observed on Next 15.4.1.

I can't find documentation that says meta tags should be updated on navigation, but it worked under Next 15.2.3. The docs say that the "contents of head get cleared upon unmounting the component," but that doesn't seem to be happening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MetadataRelated to Next.js' Metadata API.locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions