Developer URL helpers
Lightweight og image api helpers for building Dynamic OG Image API URLs. This is not a full SDK and is not published to npm.
This Hostinger build does not serve /api/og. Use the builder with a Cloudflare Pages origin, or generate PNGs in the browser with the OG Image Generator.
URL builder
Astro
---
import { buildOgApiUrl } from "../lib/og-sdk/url";
const og = buildOgApiUrl("https://socialimagekit.com", {
title: "Ship better link previews",
subtitle: "1200×630",
template: "kit-feature",
theme: "midnight",
});
---
<meta property="og:image" content={og} />Next.js
import { buildOgApiUrl } from "@/lib/og-sdk/url";
export default function Page() {
const og = buildOgApiUrl(process.env.NEXT_PUBLIC_OG_ORIGIN!, {
title: "Launch notes",
template: "blog-rule",
format: "png",
});
return <meta property="og:image" content={og} />;
}React
import { buildOgApiUrlStrict } from "./og-sdk/url";
const src = buildOgApiUrlStrict("https://socialimagekit.com", {
title: "Weekly digest",
template: "dispatch-digest",
theme: "forest",
});
// <img src={src} width={1200} height={630} alt="" />Plain HTML
<!-- Cloudflare origin only -->
<img
src="https://socialimagekit.com/api/og?title=Hello&template=kit-feature&theme=indigo&format=png"
width="1200"
height="630"
alt=""
/>Errors
invalid_params/unknown_template/unknown_font/invalid_color/invalid_size— JSON error body with short TTL cache.- Max title 120, subtitle 160, width 1200, height 630. No remote image URLs in v1.
- Rate limited (~30/min/IP on Cloudflare). Not a guaranteed SLA.
Frequently asked questions
Short answers about OG images, sizes, missing previews and how this free site works.
Is this an npm package?
No. Helpers live in the open-source site repo (src/lib/og-sdk/url.ts). Copy the functions or import them in this monorepo. We do not auto-publish to npm.
Does /api/og work on Hostinger?
No. Hostinger builds ship PHP preview only. Dynamic /api/og requires Cloudflare Pages Functions. Point the URL builder at a Cloudflare origin if you use that stack.
Are there API keys?
Not for the free public endpoint. Rate limits and size caps apply. Do not claim unlimited uptime.