OGXOGX

ogx()

The main function for generating OG images with presets

The ogx function is the primary way to generate OG images using built-in presets.

Signature

function ogx(config: OGXConfig): Promise<Buffer>

Usage

import { fontRegistry, ogx } from '@ogxjs/core';

await fontRegistry.registerInterFromUrl([400, 700]);

const png = await ogx({
  preset: 'docs',
  title: 'My Page Title',
  description: 'Page description here',
  siteName: 'My Site',
  colorScheme: 'dark',
});

Common Options

OptionTypeDescription
preset'docs' | 'blog' | 'social' | 'minimal'Template to use
titlestringMain heading
colorScheme'dark' | 'light'Color theme
widthnumberImage width (default: 1200)
heightnumberImage height (default: 630)
cachebooleanEnable caching (default: true)

Each preset has additional options. See the Presets section for details.

Platform Targeting

Generate images optimized for specific platforms:

const png = await ogx({
  preset: 'social',
  title: 'My Post',
  platform: 'instagram', // 1080x1080
});

Available platforms: meta, twitter, instagram, pinterest, youtube, marketplace.

On this page