Skip to main content
Complete TypeScript type definitions for the @ogify/core library. These types provide full type safety when creating templates and configuring renderers.

Core Types

OgTemplateParams

Base type for template parameters. All template parameter types should extend this.
Parameters are the data that gets injected into templates to create personalized OG images. Values can be:
  • Strings: Text content (titles, descriptions, names)
  • String Arrays: Lists of tags, categories
  • Numbers: Counts, dates, metrics
  • Booleans: Flags, toggles, states

OgTemplate

Complete definition of an Open Graph image template. A template is a reusable blueprint for generating OG images.
function
required
Function that generates the template output. Receives OgTemplateOptions & { params: TParams } and can return:
  • ReactNode — JSX element tree passed directly to Satori (recommended)
  • string — HTML string parsed with satori-html before Satori
  • Promise of either — async renderers are fully supported
Renderer context props:See Rendering Pipeline for details.
Returning null or undefined at the root will throw a clear error instead of silently failing later in the Satori pipeline.
Satori does not support dangerouslySetInnerHTML. For inline styled text in JSX templates, use htmlSnippet to parse trusted HTML fragments into Satori-compatible flex word containers.
OgFontConfig[]
required
Custom fonts to use in this template. Must be a non-empty array — validateTemplate throws at registration time if fonts is missing.
OgEmojiProvider
Optional emoji provider to use in this template. If not specified, defaults to 'noto'.

OgTemplateRenderer

Configuration for the TemplateRenderer class. Defines available templates, global defaults, and lifecycle hooks.
object
required
Map of template definitions to register, keyed by template ID
object | function
Shared parameter values applied to all templates. These values are merged with user-provided parameters, with user values taking precedence.
OgCacheConfig
Cache configuration for fonts and icons. When provided, enables LRU caching to improve performance by reducing redundant network requests.
function
Hook called before rendering. Useful for logging, analytics, parameter validation, authentication checks, and rate limiting.
function
Hook called after rendering. Useful for caching generated images, cleanup operations, sending notifications, and updating metrics.

Font Configuration

OgFontConfig

Configuration for a font used in OG image templates. Fonts can be loaded from three sources (in priority order):
  1. Pre-loaded binary data (via data property)
  2. Remote URL (via url property)
  3. Google Fonts API (automatic detection based on name)
string
required
The font family name (e.g., ‘Inter’, ‘Roboto’, ‘Merriweather’)
number
default:400
Font weight (100-900)
'normal' | 'italic'
default:"normal"
Font style
string
URL to the font file (for custom/self-hosted fonts)
Buffer | ArrayBuffer
Pre-loaded font binary data
'woff' | 'ttf'
default:"woff"
Font file format

OgFontFormat

Supported font file formats.
  • woff: Web Open Font Format (modern, compressed)
  • ttf: TrueType Font (legacy, larger file size)

Template Options

OgTemplateOptions

Props passed to the template renderer function, merged with params. Also available as options in renderToImage.
The renderer is always called as:
Templates always receive the original width/height values. The scale option only affects Resvg rasterization — not Satori layout. See Scale & Supersampling.
OgFontConfig[]
Custom fonts to use in this template
OgEmojiProvider
Optional emoji provider to use in this template
number
default:1200
Optional custom width in pixels. Templates always receive the original width/height values — scale is applied at the rasterisation step.
number
default:630
Optional custom height in pixels
boolean
default:false
Enable Right-to-Left text direction
number
default:1
Supersampling scale factor for higher-quality PNG output. Satori renders the SVG at the original width × height; Resvg then rasterises it at width × scale pixels wide.Constraints:
  • Float values are supported (1.25, 1.5, etc.)
  • Values below 1 are clamped to 1
  • Values above 4 are clamped to 4 (prevents OOM)
  • Output PNG file size increases proportionally to scale²

Emoji Providers

OgEmojiProvider

Supported emoji providers for rendering emoji characters in OG images. Each provider offers a different visual style.
Twitter’s emoji set - colorful, rounded style
Microsoft’s Fluent emoji - 3D style with color
Microsoft’s Fluent emoji - flat 2D style
Google’s Noto Color Emoji - current standard (default)
Google’s blob-style emoji - deprecated but still available
Open-source emoji with outlined style

Utility Types

OgTemplateRenderResult

Return type of a template renderer function.
  • ReactNode — passed directly to Satori (JSX templates)
  • string — parsed with satori-html, then passed to Satori

HtmlSnippetOptions

Options for htmlSnippet word-container layout.
'flex-start' | 'center' | 'flex-end'
default:"flex-start"
Flex main-axis alignment for the word container.
number
Gap between word items in pixels. Overrides the font-size-derived default.
number
Font size in pixels. Used to derive gap when gap is omitted (~29% of font size).

Caching

OgCacheConfig

Cache configuration for fonts and icons. Supports two caching strategies: memory and filesystem.
Fast in-memory cache with LRU eviction
'memory'
required
Memory-based caching strategy
number
default:3600000
Time-to-live in milliseconds (default: 1 hour)
number
default:100
Maximum number of items to cache