Solution skill
You are attempting to export "metadata" from a component marked with "use client"
Complete solution
Move the metadata export into a server component, usually the parent layout or page. The build passes once no "use client" file exports metadata. Applies to: Next.js 13+ app router.
TL;DR
Move the metadata export into a server component, usually the parent layout or page. The build passes once no "use client" file exports metadata.
The exact error
You are attempting to export "metadata" from a component marked with "use client"Steps to fix
- Open the file the build error names and confirm it has "use client" at the top
- Cut the metadata export out of that file
- Paste it into the nearest server component (the layout.tsx or page.tsx above it)
- Run the build again; the error should be gone
When this applies
- Next.js 13+ app router
- You want page metadata but the file also needs client interactivity
When this does NOT apply
- Pages router (metadata works differently there)
- Metadata that must be computed from client-side state
Tool + versions
Next.js 13+ app router
Why it happens
Metadata is a server-only feature. A "use client" file runs in the browser where the metadata API does not exist, so Next.js rejects the export at build time.
Edge cases
- generateMetadata has the same restriction
- You can still read the metadata in the client component via props
Where this came from
Resolved from a real public thread: https://nextjs.org/docs/app/building-your-application/optimizing/metadata (docs:metadata-client-component).
Evidence
Asked: build fails when a client component exports metadata. Verified fix: metadata exports must live in a Server Component; move them to the parent layout or page. Source: https://nextjs.org/docs/app/building-your-application/optimizing/metadata
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_0KIE72x25FAJ-KMcKmWn6g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">You are attempting to export "metadata" from a component marked with "use client" <span>— Vectle</span></a>