vercel / vercel/next.js

Metadata tags are ordered after hoisted style tags, which can make metadata undetectable by some platforms

Open
#79,263 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CSS Metadata Upstream
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://github.com/RJWadley/next-meta-bug

To Reproduce
  1. Include more than 32KB (to break slack) or 512KB (to break facebook) of style tags that have both a precedence and an href
  2. Send the deployed link in a slack chat, or paste it in Facebook's post composer

For convenience, I've already deployed the provided sample:
https://next-meta-bug.vercel.app/fails will not display metadata when shared via Slack or Facebook
https://next-meta-bug.vercel.app/works will display metadata when shared via Slack or Facebook

Current vs. Expected behavior

The core of the issue is that Next will include it's metadata tags after any hoisted style tags. Most social sites do not parse the entire site when searching for metadata. This means if the style tags exceed a certain size they will be undiscoverable by some social sites.

Metadata tags that are important for social sharing should be ordered before metadata tags that are not to prevent the metadata tags from being undiscoverable.

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: N/A
  pnpm: 9.15.5
Relevant Packages:
  next: 15.3.2 // Latest available version is detected (15.3.2).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Metadata, CSS

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

Other (Deployed), Vercel (Deployed)

Additional context

Style tag hoisting was introduced in React 19, and it's by far the easiest way to reproduce this sort of issue. It might also be possible to reproduce with other types of tags, like if an obscene amount of some other resource were included.

Slack is the easiest to break, since it only loads the first 32kb of content. You may also find this article useful. it helped me diagnose this issue: https://blog.daveallie.com/slack-link-unfurling/

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 deployed /fails and /works reproduction URLs and compare the generated document head, focusing on the ordering of metadata and hoisted style tags. Confirm the behavior with the stated Slack and Facebook size limits; done means important metadata appears before large style content so both platforms can detect it.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.