Next.js Discord

Discord Forum

generateMetadata do not set the tags when exist await params.

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Hey,
There is a strange "bug."
Whenever I put await params inside the function generateMetadata(), the SEO tags are not set.
If I reload the page manually, the tags do not show, but when I save in my text editor and the app reloads, the tags appear. This is very strange...

import type { Metadata } from "next";

type Props = {
    params: Promise<{ locale: string; page: string }>;
};


// DOES NOT WORK 
export async function generateMetadata({ params }: Props): Promise<Metadata> {
    const { page } = await params;
    console.log("page", page);
    return { title: "test" };
}

// WORKS
export async function generateMetadata({ params }: Props): Promise<Metadata> {
    return { title: "test" };
}

export default async function Page({ params }: Props) {
    const { page } = await params;
    return <div>{page}</div>;
}


Layout is clean, only <html><body>

How can I fix it?

0 Replies