"Use Client" Directive on metadata
Answered
Barbado da Terceira posted this in #help-forum
Barbado da TerceiraOP
So, this is my code for layout.tsx
When trying to deploy onto Vercel I get this issue:
export const metadata = {
title: 'nextOS',
description: 'webOS made in nextJS',
}
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}When trying to deploy onto Vercel I get this issue:
Error:
x You are attempting to export "metadata" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https://nextjs.org/
| docs/getting-started/react-essentials#the-use-client-directive
|
|
,-[/vercel/path0/src/pages/layout.tsx:1:1]9 Replies
Is this all the code for layout.tsx? That is, there is no "use client" directive at the beginning of the file?
And is next.config.js clean or any packages being used?
And is next.config.js clean or any packages being used?
@vordgi Is this all the code for layout.tsx? That is, there is no "use client" directive at the beginning of the file?
And is next.config.js clean or any packages being used?
Barbado da TerceiraOP
I don't have a next.config.js, i have a next.config.mjs. and if i add a "use client" at the top of the file. It still keeps showing the same error.
@Ray is the layout.tsx inside the pages folder?
Barbado da TerceiraOP
Yeah
@Barbado da Terceira Yeah
metadata api only work in app folder
Answer
@Ray metadata api only work in app folder
Barbado da TerceiraOP
damn
@Barbado da Terceira damn
you need to add the metatag within the <Head /> component
from
next/heador use [next-seo](https://github.com/garmeeh/next-seo)