Native fetch, zero extra dependencies, 0 MB added to your bundle. Works on Express, Fastify, Vercel, and AWS Lambda.
ESM or CommonJS, Express or serverless functions — same API call either way.
// render.js — works anywhere Node 18+ fetch is available
export async function htmlToImage(html, { width = 1200, height = 630 } = {}) {
const res = await fetch('https://api.renderpix.dev/v1/render', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.RENDERPIX_API_KEY}`,
},
body: JSON.stringify({ html, width, height, format: 'png' }),
})
if (!res.ok) throw new Error(`RenderPix error: ${res.status}`)
const { url } = await res.json()
const img = await fetch(url)
return Buffer.from(await img.arrayBuffer())
}
| Approach | Vercel / Lambda | Bundle overhead | Full CSS | Setup time |
|---|---|---|---|---|
| RenderPix API | Yes | 0 MB | Yes | < 5 min |
| Puppeteer | No | ~300 MB | Yes | 2–4 hrs |
| @vercel/og (Satori) | Yes | < 5 MB | Subset only | 1–2 hrs |
| node-html-to-image | No | ~300 MB | Yes | 1–2 hrs |
Node.js 18+ includes native fetch — no node-fetch needed. If you're on Node 16 or below, add node-fetch or upgrade. The code examples above use native fetch throughout.
Yes. Your function makes a standard outbound HTTPS request — no binary layer, well under the 250 MB size limit. Works on Vercel Hobby and Pro. Use it in api/ routes or App Router route handlers.
Include a <link> tag for Google Fonts or a @font-face block in your HTML string. The renderer waits for fonts to load before capturing, so your typography renders exactly as in a browser.
Yes — set "format": "webp" in the request body. WebP output is typically 30–50% smaller than PNG for the same visual quality, which makes a difference if you're serving OG images from a CDN.
Free tier: 100 renders/month. Paid plans start at $9/month for 2,000 renders with no rate limiting per second — you can fire concurrent requests. Check the pricing page for details.
No binary dependencies, no cold starts. Free tier, no credit card required.