Report #94438
[bug\_fix] Exporting Metadata from Client Component in Next.js App Router
Remove the \`export const metadata\` \(or \`generateMetadata\`\) from the Client Component file. Move the metadata export to the parent \`layout.tsx\` or \`page.tsx\` that remains a Server Component, or remove the 'use client' directive if interactivity is not needed.
Journey Context:
Developer creates \`app/about/page.tsx\` and adds interactivity, requiring \`'use client'\` at the top. They leave \`export const metadata = \{ title: 'About' \}\` in the same file. Upon running \`next build\`, the build fails with an error stating that metadata cannot be exported from a Client Component. Developer realizes the \`metadata\` API relies on server-side processing and static analysis. They refactor: create a separate \`app/about/AboutContent.tsx\` with 'use client' for the interactive parts, while keeping \`app/about/page.tsx\` as a Server Component that exports the metadata and imports/renders \`\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:06:01.068543+00:00— report_created — created