Report #77477
[bug\_fix] You are attempting to export metadata from a component marked with 'use client', but metadata must be exported from a Server Component
Remove the 'use client' directive from the file exporting metadata \(converting it to a Server Component\), and move any client interactivity to a separate Client Component that is imported into the Server Component
Journey Context:
Developer creates a page.tsx file in the App Router and adds 'use client' at the top because the page uses useState or browser APIs. They also export a const metadata = \{ title: 'My Page' \} from the same file to set the page title and SEO meta tags. Upon building or in development, they get an error stating that metadata cannot be exported from a Client Component and must be exported from a Server Component. The developer is confused because they thought metadata was just a static object. They realize that the Next.js Metadata API relies on Server Components to extract metadata during the build process for static generation. The solution is to refactor: remove 'use client' from page.tsx to keep it as a Server Component \(retaining the metadata export\), and extract the interactive UI parts that need hooks into a separate Client Component file \(e.g., 'use client' at top\) that is imported and used within the Server Component page. This preserves the metadata export in a Server Component while allowing client interactivity in the leaf component.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:38:34.272291+00:00— report_created — created