Skip to main content
While OGify comes with production-ready templates (browse them at the Template Gallery), you may want to create your own to match your brand’s unique identity.

defineTemplate

The defineTemplate helper is the core building block. It ensures type safety and validates your template at registration time. Templates use a React-like JSX syntax (recommended) or return HTML strings. Both are converted to PNG via the rendering pipeline.
Save template files as .tsx and set "jsx": "react-jsx" in your tsconfig.json. You do not need React as a runtime dependency — OGify uses Satori’s JSX factory.

defineTemplate

Helper function to define a template with type safety, including the full renderer context (params, width, height, isRTL, fonts, emojiProvider, scale).

Renderer Context

Your renderer receives all render options plus params. Use these props to build dynamic layouts: See Rendering Pipeline for the complete reference.

Styling

We use Satori under the hood, which supports a subset of CSS properties. For a complete list, see Styles.

tw Prop (Tailwind-like)

Use the tw prop on JSX elements for utility classes. Combine with clsx for conditionals:

Inline Styles

Use the style prop for CSS properties not covered by utilities:

Inline HTML Styling

For styled words inside text, use htmlSnippet:
Not all Tailwind classes are supported. OGify maps common utility classes to Satori-compatible inline styles.

HTML String Alternative

You can still return HTML strings from renderer. Classes on class are parsed via satori-html:
JSX is recommended for better type safety, conditional rendering, and composition. See the full HTML String Rendering guide.

Dynamic Content

Your renderer receives params from renderToImage. Use JSX expressions to inject dynamic values:

Best Practices

JSX templates give you type safety, conditional rendering ({condition ? ... : null}), and composition without string interpolation.
Satori is powerful but has limitations compared to a full browser engine. Avoid complex CSS selectors or deeply nested absolute positioning.
Flexbox is the most reliable layout mode in Satori. Use the tw prop with flex, flex-col, items-center, justify-between, etc.
Ensure your template handles RTL content gracefully if you plan to support international audiences.

Features

Rendering Pipeline

How templates become PNG images

Caching

A smart caching layer to improve performance

Font Loader

Using Google Fonts or custom fonts

Emoji Loader

Rendering emojis in your templates

RTL Support

Right-to-left language support

Styles

Supported CSS properties