nextjs
app-router
ai_generated
true
Error: You are attempting to export 'metadata' from a component marked with 'use client'
ID: nextjs/metadata-not-supported-client
97%Fix Rate
98%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 14 | active | — | — | — |
Root Cause
Next.js metadata export (for SEO) is only supported in Server Components, not Client Components.
genericWorkarounds
-
97% success Export metadata from a Server Component (layout.tsx or page.tsx without 'use client')
Keep metadata in the page/layout, keep interactive parts in child Client Components
Sources: https://nextjs.org/docs/app/building-your-application/optimizing/metadata
-
92% success Use generateMetadata() function for dynamic metadata based on params
export async function generateMetadata({ params }) { return { title: ... } }
Dead Ends
Common approaches that don't work:
-
Using document.title in useEffect instead
70% fail
Loses SEO benefits; meta tags aren't set during SSR
-
Removing 'use client' from the page
55% fail
May break if the component uses hooks or browser APIs
Error Chain
Frequently confused with: