I would like to update pages title when navigating. I could figure out the static version of it but how can we use it dynamically.
Exp: If we are navigating to and item and want to mention the item's name in the title.
I used the code below to update the metadata but would like to know how can we make it dynamic on page load?
I am using the code below for the static method before the server side component definition.
Exp: Metadata for contact page:
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "Contact Us",
description:
"Get in touch with us using our contact list. We will get back to you as soon as possible.",
};
From Next.js docs: https://nextjs.org/docs/app/building-your-application/optimizing/metadata
Dynamic Metadata
You can use generateMetadata function to fetch metadata that requires dynamic values.