renderTemplate) converts template output into a PNG buffer through a five-step pipeline powered by Satori and Resvg.
Pipeline Overview
1
Font Loading
All fonts from the template (or
options.fonts override) are loaded in parallel. Sources are resolved in priority order: pre-loaded data → remote url → Google Fonts API.2
Markup Generation
The template
renderer is called with merged parameters and render options. It returns either an HTML string or a React node tree.3
Element Tree
- HTML string → parsed with
satori-html(class→tw) - React node → passed directly to Satori (no HTML parsing step)
4
SVG Rendering
Satori renders the element tree to SVG at the original
width × height (default 1200 × 630). Font sizes and layout values stay correct regardless of scale.5
PNG Rasterization
Resvg rasterizes the vector SVG at
width × scale pixels wide (default scale = 1). See Scale & Supersampling for details.Renderer Context
Everyrenderer function receives OgTemplateOptions merged with params:
Merged template parameters (
sharedParams + user params from renderToImage). User values take precedence.Canvas width in pixels. Always the original dimension — not affected by
scale.Canvas height in pixels. Always the original dimension.
Font override from
renderToImage options. Falls back to the template’s fonts array when omitted or empty.Emoji provider override. Falls back to the template’s
emojiProvider, then 'noto'.Enable right-to-left text direction and layout mirroring.
Supersampling factor passed through for awareness. Templates should not use
scale for layout — Satori always renders at width × height. Only Resvg uses scale for final PNG dimensions.Return Types
JSX vs HTML String
- JSX (Recommended)
- HTML String
Return a React-like element tree using Satori-compatible elements. Use the Save template files as
tw prop for Tailwind-like utilities and style for inline CSS..tsx and ensure your tsconfig.json has "jsx": "react-jsx".Scale / Supersampling
scale only affects Resvg PNG output — not Satori layout. Templates always design against original width/height.
Scale & Supersampling
Why scale does not change layout, correct vs incorrect usage, and output dimensions
Pass
scale via renderToImage options — not in template layout code:
Default Dimensions
OGify uses the Open Graph protocol recommended dimensions:- Width: 1200px
- Height: 630px
- Aspect ratio: 1.91:1 (works across Facebook, Twitter, LinkedIn, Discord)