Dynamic metadata in nextjs
June 27, 2024
WARNING: This post is over a year old. Some of the information this contains may be outdated.
// use for somewhere need
import { cache } from "react";
export const getPost = cache(() => {
console.log("called getPost()");
return "post";
});
// use in page
import { Metadata } from "next";
export function generateMetadata(): Metadata {
const posts = getPost();
return {
title: "title",
};
}
const Page = async () => {
const posts = getPost();
return <article>{"article"}</article>;
};
export default Page;
Comments are not enabled for this post.