Next.js Discord

Discord Forum

Buggy Nextjs Metadata

Unanswered
Golden paper wasp posted this in #help-forum
Open in Discord
Avatar
Golden paper waspOP
I have a metadata object in my layout file that doesn't show up titles, I am using the Nextjs 13
/app
version


export const metadata: Metadata = {
title: {
default: 'Web Title',
template: '%s | Web Title',
},
description: '',
category:
'',
abstract:
'',
keywords: [

],
};

6 Replies

Avatar
joulev & fuma pray for Schneider
Is this file marked with “use client”?
Avatar
Golden paper waspOP
Ya
Avatar
joulev & fuma pray for Schneider
Then it doesn’t work since the metadata api only works in server components
Avatar
Golden paper waspOP
Appreciate it man thanks. I removed the “use client” it works on that layout. But the template doesn’t from other pages
Avatar
joulev & fuma pray for Schneider
All pages must also be server components for the metadata api to work
You can make a wrapper like this
// page.client.tsx
"use client";
export default function PageClient() {
  useSomeHook();
  return <Something />;
}

// page.tsx
import PageClient from "./page.client";
export default function Page() {
  return <PageClient />;
}
export const metadata = { title: "My Page" };