nextjs - 💡(How to fix) Fix Title tag insert into body (generateMetadata) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#90023Fetched 2026-04-08 00:20:55
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Code Example

2. dev server start: `npm install`
3. dev server start: `npm run build`
4. dev server starts `npm run start` (via Supervisor)
5. Go to page `domain.com/shared/[id]`

### Current vs. Expected behavior

Current:
tag `<title>...</title>` is located inside `<body>...</body>`

Expected behavior:
tag `<title>...</title>` is located inside `<head>...</head>`


### Provide environment information
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

To Reproduce

  1. I have a component app/shared/[shareId]/page.tsx with the contents:
import ClientContent from "@/app/shared/[shareId]/ClientContent";
import type {Metadata} from 'next'

type Props = {
  params: Promise<{ shareId: string }>
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}

export async function generateMetadata(
  {params}: Props
): Promise<Metadata> {
  const API_URL = process.env.NEXT_PUBLIC_API_URL;
  const APP_NAME = process.env.NEXT_PUBLIC_APP_NAME;
  const shareId = (await params).shareId
  // fetch post information
  const post = await fetch(`${API_URL}/api/${shareId}`).then((res) =>
    res.json()
  )
  return {
    title: `${APP_NAME} - ${post.title}`,
    description: '',
  }
}
export default function Page() {
  // Pass any initial data or props to the client component if needed
  return <ClientContent/>;
}
  1. dev server start: npm install
  2. dev server start: npm run build
  3. dev server starts npm run start (via Supervisor)
  4. Go to page domain.com/shared/[id]

Current vs. Expected behavior

Current: tag <title>...</title> is located inside <body>...</body>

Expected behavior: tag <title>...</title> is located inside <head>...</head>

Provide environment information

Binaries:
  Node: 21.6.0
  npm: 8.19.4
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.1.4 // There is a newer version (16.1.6) available, upgrade recommended!
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
⚠ There is a newer version (16.1.6) available, upgrade recommended!
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

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

Metadata

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

Other (Deployed)

Additional context

With "next": "^16.2.0-canary.46", the problem still persists

extent analysis

Fix: Correct the generateMetadata signature

Next 16 expects plain objects for params and searchParams.
Declaring them as Promise<…> makes Next treat the page as a client‑side render, so the <title> ends up in the <body>.
Change the type signature (and the import)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix Title tag insert into body (generateMetadata) [1 comments, 2 participants]