Default Template — Dark Gradient

A clean dark background with title, description, accent bar, and brand name. Works for any page type.

Default OG image template preview
Default templateTypeScript
import { createOGImageSVG } from "react-ssr-seo-toolkit/og";

const svg = createOGImageSVG({
  title: "How to Build an SSR App with React",
  description: "A complete guide to server-rendered React with proper SEO.",
  brand: "My Blog",
  accentColor: "#6366f1",
  // template: "default" is the default
});

// Serve from Express:
app.get("/og/default.svg", (req, res) => {
  res.type("image/svg+xml").send(svg);
});

// Dynamic endpoint with query param:
app.get("/og/:slug.svg", (req, res) => {
  const page = getPageBySlug(req.params.slug);
  res.type("image/svg+xml").send(
    createOGImageSVG({ title: page.title, brand: "My Blog" })
  );
});

// Use as og:image:
openGraph: {
  images: [{ url: "https://mysite.com/og/my-post.svg", width: 1200, height: 630 }]
}

Article Template — Light with Category Tag

A light background with a colored category pill, author byline, and publication date. Great for blog posts and news articles.

Article OG image template preview
Article templateTypeScript
const svg = createOGImageSVG({
  title: "Premier League Preview 2026",
  description: "Everything you need to know about the upcoming season.",
  template: "article",
  category: "Sports",
  author: "James Walker",
  dateString: "May 8, 2026",
  brand: "Trustix UK",
  accentColor: "#e63946",
});

Sports Event Template — VS Layout

A dark dramatic layout with home team vs away team, separated by a glowing divider. Pass homeTeam and awayTeam to activate the VS layout.

Sports event OG image template preview
Sports event templateTypeScript
const svg = createOGImageSVG({
  title: "Liverpool vs Arsenal",
  template: "sports-event",
  homeTeam: "Liverpool",
  awayTeam: "Arsenal",
  eventDate: "Saturday, May 15, 2026 · 17:30",
  brand: "Trustix UK",
  accentColor: "#ffd700",
});

Convert to PNG (optional)

SVG works directly as og:image in most platforms. For maximum compatibility, convert to PNG with sharp — no headless browser needed.

SVG → PNG with sharpTypeScript
import sharp from "sharp";
import { createOGImageSVG } from "react-ssr-seo-toolkit/og";

app.get("/og/:slug.png", async (req, res) => {
  const page = await getPage(req.params.slug);

  const svg = createOGImageSVG({
    title: page.title,
    description: page.excerpt,
    brand: "Trustix UK",
  });

  const png = await sharp(Buffer.from(svg))
    .resize(1200, 630)
    .png()
    .toBuffer();

  res
    .type("image/png")
    .set("Cache-Control", "public, max-age=86400")
    .send(png);
});
!

sharp is an optional dependency — install separately with npm install sharp. It is not bundled with react-ssr-seo-toolkit to keep the package size minimal.

Full Options Reference

OptionTypeDescription
titlestringMain headline (required)
descriptionstring?Subtitle / description
template"default" | "article" | "sports-event"Visual template
brandstring?Brand name shown in corner
backgroundColorstring?Override background color
textColorstring?Override text color
accentColorstring?Override accent / highlight color
categorystring?Category pill (article template)
authorstring?Author byline (article template)
dateStringstring?Display date (article template)
homeTeamstring?Home team name (sports-event)
awayTeamstring?Away team name (sports-event)
eventDatestring?Event date text (sports-event)

Features Demonstrated

No External Service

Pure SVG generation — no Cloudinary, no Vercel Edge, no API keys. Works anywhere Node.js runs.

3 Built-in Templates

Default (dark gradient), Article (light with category), Sports Event (VS layout). Each is fully customizable.

Text Wrapping

Long titles and descriptions are automatically wrapped across lines and truncated with an ellipsis if needed.

SSR-Ready

Runs on the server — generate at build time, serve dynamically, or cache with HTTP Cache-Control headers.