Skip to main content
When you share a link on Twitter, Discord, Slack, or LinkedIn, the platform renders a preview card. The image in that card comes from the og:image meta tag. This guide shows how to generate OG images programmatically — define the image as a component, render to PNG at build time.

How it works

The approach is the same one Next.js uses under the hood with @vercel/og:
  1. Satori renders a component (JSX-like object) to SVG — supports flexbox, text, images, gradients
  2. resvg converts the SVG to a PNG bitmap
  3. The PNG is saved to public/ and referenced in og:image meta tags
No React required. Satori uses plain objects that look like React elements.

Setup

Install satori and @resvg/resvg-js:

Write the OG component

Create a generation script at scripts/generate-og.ts. The “component” is a plain object tree — same structure as React elements, but no framework needed:
Run it:

Component patterns

Embedding images

Use SVGs as data URIs in <img> tags:

Background gradients

Satori supports radialGradient and linearGradient via CSS:

Bottom bar with badge + URL

Satori limitations

Satori renders a subset of CSS. Key things to know:
SupportedNot supported
Flexbox (display: flex)Grid (display: grid)
border-radius, box-shadowfilter, backdrop-filter
background (gradients, colors)clip-path
position: absolute/relativetransform (limited)
Google Fonts (ttf/woff)Local system fonts, woff2
<img> with data URIs or URLs<svg> inline (use <img> with data URI)
Satori doesn’t support woff2 fonts. When loading from Google Fonts, use the Googlebot user agent to get ttf format: { headers: { 'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1)' } }.

Adding OG meta tags

Reference the generated image in your HTML <head>. In a static site build script, inject these after the <title>:
The og:image URL must be an absolute URL (with https://), not a relative path. Social media crawlers fetch images from the full URL, not relative to the page.

Integrating with the build

Call the OG generation script from your build script so images are always up to date:

Future: @vertz/og

We plan to ship OG image generation as a framework-level feature. The envisioned API:
This would auto-load fonts from your theme config, provide pre-built templates matching @vertz/theme-shadcn, and integrate with vertz build to generate images automatically. See the tracking issue for progress.

Static Sites

Full guide on deploying static Vertz sites

Styling

Theme tokens and the css() API