Next.js: You are attempting to export "metadata" from a component marked with "use client", which is disallowed
metadata/generateMetadata can only be exported from Server Components.
You are attempting to export "metadata" from a component marked with "use client", which is disallowedYou are attempting to export "generateMetadata" from a component marked with "use client"Either remove the export, or the "use client" directivemetadata export use client disallowed Meaning
Remove "use client" from the page/layout that exports metadata, or move the interactive part into a separate Client Component and keep the page server-side. Metadata is evaluated on the server.
Common causes
"use client"at the top ofpage.tsxthat exports metadata- Layout marked client but exporting metadata
- Mixed server/client concerns in one file
- Copy of a client component turned into a page
- Re-export from a client module
⚡ Quick fix
- Make the page a Server Component and import a Client Component for interactivity
- Keep
export const metadata = {...}in the server file - Use
useEffect(() => { document.title = ... })only for purely client pages
Detailed fix by platform
Next.js
- tsx
// page.tsx (server) export const metadata = { title: "Home" }; export default function Page() { return <ClientPart />; }
How to diagnose
- Directive — "use client" on this file?
- Metadata — Where exported?
- Split — Server page + client child?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- createContext only works in Client Components Next.js: You're importing a component that needs createContext. It only works in a Client Component but none of its parents are marked with "use client"
- needs useState You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client"
- next build: fetch failed ECONNREFUSED (build-time API) Next.js: Error occurred prerendering page "/blog" TypeError: fetch failed { cause: Error: connect ECONNREFUSED 127.0.0.1:3000 }
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
- CORS error calling Next.js API route / route handler Browser: Access to fetch at 'https://api.example.com/api/data' from origin 'https://app.example.com' has been blocked by CORS policy (Next.js route handler)
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026