Menu

Post image 1
Post image 2
1 / 2
0

Dynamic OG Images in Next.js Without @vercel/og (1,200 630)

DEV Community·Accreditly·about 1 month ago
#UvbL11rB
#nextjs#css#html#vercel#font#route
Reading 0:00
15s threshold

I had a perfectly reasonable OG image template. Flexbox layout, custom font, a gradient background, a small CSS grid for a two-column footer with the author name and publish date. Worked in the browser. Looked great in Figma. Then I moved it into  next/og  and half of it disappeared. No errors. No warnings. Satori, the renderer behind  ImageResponse , just silently ignored the parts it doesn't support. CSS grid, gone. The  calc()  I was using for spacing, ignored. A CSS variable for the brand colour, treated as an unknown value. The fallback rendered, which was worse than if it had thrown, because I didn't notice until someone shared the link on Slack and the preview was visibly broken. If you've been building dynamic OG images in Next.js and hit the same wall, this article is about the other way to do it: rendering your template in an actual browser via an API, and serving the resulting PNG from your  opengraph-image  route.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More