Next.js Discord

Discord Forum

Generate opengraph-image at build time for dynamic routes

Unanswered
Cinnamon posted this in #help-forum
Open in Discord
Avatar
CinnamonOP
Generating an image though the opengraph-image.tsxfile convention for routes generated via generateStaticParams()will result in only one lambda function being deployed, instead of being generated at build time.

In this case its a blog, posts get generated at build time via generateStaticParams(). Why do the open-graph images not get generated at build time as well?

Example opengraph-image.tsx:
`ts export const contentType = "image/png"; export const runtime = "nodejs"; export const dynamic = "force-static"; // Image generation export default function Image({ params }: { params: { slug: string } }) { ...

0 Replies