NEXT.JS & REACT

Satori CSS Limitations: What Breaks in Next.js OG Images

You built an Open Graph card in JSX, it looked perfect in the browser, and then your ImageResponse route returned an error or a mangled layout. The cause is almost always one of the Satori CSS limitations: the renderer does not run a browser, so it does not understand most of the CSS you take for granted. Every failed render means a blank social preview, and nobody sees the page you wanted to share.

Satori is the open-source library from Vercel that turns a JSX tree into an SVG, which is then rasterised to a PNG. It is what @vercel/og and the Next.js ImageResponse helper wrap. Because it implements its own layout engine, it supports a deliberate subset of CSS rather than the whole language.

What are the Satori CSS limitations that matter most?

The limitations that cause nearly every failure are: layout is flexbox only, CSS grid and float are not supported, any element with more than one child needs an explicit display: flex, and fonts must be loaded manually as binary data. The Satori README on GitHub lists the supported properties in full, and it is worth reading once before you write a template.

Here is the short version, written as a table you can keep next to your editor.

CSS you might writeWhat Satori doesUse this instead
display: gridNot supportedNested flex containers with flexDirection and fixed widths
floatNot supporteddisplay: flex with justifyContent
Div with two children and no displayThrows an errorAdd display: 'flex' to the parent
WOFF2 font fileCannot be parsedTTF, OTF or WOFF loaded as an ArrayBuffer
Font from a CSS @importIgnoredPass the font data to the renderer explicitly
Remote image with a relative pathFails to loadAbsolute URL or a base64 data URI

Notice what the table implies: Satori fails loudly on structure and silently on typography. A missing display throws an error you can read. A missing font quietly falls back or renders nothing, which is why the second failure is harder to spot.

Why does Satori say every div needs display flex?

Satori requires display: flex or display: none on any element that has more than one child node. Its error message states this directly: the element is expected to have an explicit display value. The reason is that Satori has no block or inline layout algorithm, so it will not guess how to stack children.

The most common trigger is mixed content. A heading that contains text and a styled span is a parent with two children, even though it looks like a single line in the browser.

// Throws: the h1 has two children (text + span)
<h1>Ship faster with <span style={{ color: '#4f8eff' }}>AI tools</span></h1>

// Works: explicit flex on the parent
<h1 style={{ display: 'flex' }}>
  Ship faster with&nbsp;
  <span style={{ color: '#4f8eff' }}>AI tools</span>
</h1>

Two side effects are worth knowing. First, flex collapses the whitespace between a text node and a span, so you must add the space back yourself. Second, a flex row will not wrap text across inline elements the way a paragraph does. If you need a long title to wrap, keep the title in one text node and put the highlighted word in a separate block.

How do you replace a CSS grid layout in an OG image?

Replace the grid with a column flex container that holds row flex containers, and give each cell an explicit width or flex: 1. A two-column card with a title on the left and a logo on the right is a single row with two children, one growing and one fixed.

The pattern that holds up across templates has three layers: an outer 1200 by 630 container, an inner padded container, and rows inside it. Fix sizes in pixels, because percentage heights depend on a parent size that Satori resolves differently from a browser. The 1200 by 630 pixel size is the ratio most platforms render for large link previews, so design to that canvas rather than scaling later.

Avoid relying on gap tricks you have not tested. Spacing through explicit margin and padding values is the safer habit, because you can see exactly what each element contributes to the layout.

Why does text render in the wrong font or not at all?

Satori renders text only in fonts you pass to it as binary data, in TTF, OTF or WOFF format, and WOFF2 is not supported. If the font is missing, text can fall back or disappear, because the renderer has no access to system fonts or to a stylesheet in your page.

The fix is to bundle a font file and read it at request time. In a Next.js route that means keeping a TTF in your project, loading it as an ArrayBuffer, and handing it to ImageResponse in the fonts array with a name, weight and style. Each weight you use needs its own file, so a bold headline and a regular subtitle means two font entries.

If you bundle the font from your own repository, check that the file is actually included in the production build. A font that loads locally but is missing on the server produces the blank-text symptom that many people report only after deploying.

How do you debug a Satori render that fails?

Debug a failing render by shrinking the template until it works, then adding elements back one at a time. Satori errors point at an element type but rarely at a line, so bisecting is faster than reading.

  1. Open the OG route directly in the browser and read the response body, not just the image slot in the page.
  2. Replace the template with one flex container containing one line of text, and confirm it renders.
  3. Add elements back one at a time, setting display: 'flex' on every parent with multiple children.
  4. Remove any grid, float or unsupported property the moment you see it.
  5. Confirm every font file is a supported format and is loaded for every weight you use.
  6. Test with a very long title and a very short one, since overflow is the most common layout bug after the first render passes.

Step six matters more than it looks. A template that works with your sample title can still clip or overflow with a real one, so test both extremes before you ship.

Is it worth writing your own Satori templates?

Writing your own templates is worth it when your card design is unusual, and not worth it when you only need a clean title card for each page. The first template teaches you the subset. The fifth one, with edge cases for long titles, missing images and non-Latin text, is where the hours go.

If you would rather start from templates already written to the Satori subset, the OG Image Generator Boilerplate from BuyCoded ships ready-made templates, bundled DejaVu Sans Regular and Bold fonts in public/fonts/, and a preview page that surfaces rendering errors immediately. Swapping in your own font means dropping TTFs into that folder and editing lib/fonts.ts, which the product page describes as about four lines of change.

For the build-it-yourself route, the BuyCoded blog has a walkthrough of the Next.js route handler and a build versus buy comparison that lays out where the time goes.

What is the most likely reason not to buy a boilerplate?

The most likely objection is that you can write one template in an afternoon, so a paid package feels unnecessary. That is true for one template. Where a package earns its price is the part after the first render: font handling, the subset rules, and a preview loop that tells you what broke. If you only ever need a single static card, build it yourself and use the table above.

The Satori project documents the same constraints publicly, and the Vercel OG image generation docs describe how the helper wraps it. Neither is hidden knowledge, so the real trade is your hours against a tested starting point.

What should you do next?

Open the catalog, compare the OG image boilerplate with the other developer packages, and pick the one that matches the stack you ship in. Everything on the BuyCoded products page is a download you can read through the same day, so you can check the template files against the rules in this article before you build anything on top of them.

Sources: the Satori README on GitHub for supported CSS and font formats, and the Vercel OG image generation documentation for the ImageResponse wrapper.

Frequently asked questions

Does Satori support CSS grid?

No, Satori does not support CSS grid or float. Its layout engine implements flexbox only. To recreate a grid, nest flex containers: a column container holds row containers, and each cell gets a fixed width or flex: 1. This covers almost every OG image layout, since cards rarely need more than two or three regions.

Why does Satori say my div needs display flex?

Satori requires display: flex or display: none on any element with more than one child node. It has no block or inline layout, so it will not guess how to arrange children. Text mixed with a styled span counts as two children, so add display: flex to the parent and restore any lost spacing manually.

Can Satori use WOFF2 fonts?

No, Satori cannot parse WOFF2 files. It accepts TTF, OTF and WOFF font data, which you must pass to the renderer explicitly as an ArrayBuffer. Each weight you use needs its own font entry. If your project only has WOFF2 files, download or convert a TTF version for the OG route.

Why does my OG image text disappear in production?

Text disappears when the font file is not available to the server at render time. Satori cannot use system fonts or page stylesheets, so a font that loads locally but is missing from the production build renders blank or falls back. Confirm the file is bundled and read from a path that exists on the server.

What size should a Next.js OG image be?

Design your OG image at 1200 by 630 pixels, the ratio most platforms use for large link previews. Set the width and height on ImageResponse to match, and keep important text away from the edges, since some platforms crop slightly. Fixed pixel sizes also keep Satori layouts predictable.