Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a template renderer when your Open Graph (OG) image is a designed card built from fields such as a title, author, or avatar. Use Playwright or Puppeteer when the image must show a real page or element exactly as a browser renders it. In both cases, deploy a publicly fetchable image endpoint and reference its absolute URL in <meta property="og:image">. Vercel recommends 1200×630 pixels for OG images.

Choose the right automation pattern

The most reliable implementation starts by deciding what the image represents. A share card is not the same thing as a screenshot of a page.

Decision Template renderer (Vercel OG/Satori) Browser screenshot (Playwright/Puppeteer)
Input Structured values such as title, author, logo and image A URL, viewport, page state or selected element
Best fit Repeatable branded cards for articles, products or profiles The actual visual state of a rendered page
Rendering Supported JSX/HTML and CSS converted to SVG/PNG A browser engine paints the page before capture
Main constraint Limited CSS and asset/runtime limits Browser startup, deterministic state and runtime resources

Use a template for structured content

Template rendering is preferable when every record supplies known fields. You control the composition, output is predictable, and you avoid launching a browser for every request. Vercel’s OG workflow uses Satori and Resvg to convert supported HTML/CSS into a PNG. Satori does not implement the full browser CSS model: flexbox works, while display: grid does not, and its SVG is not guaranteed to match browser-rendered HTML exactly. Fonts must be TTF, OTF or WOFF, and Vercel documents a 500 KB maximum bundle including fonts, images, JSX and other assets.

Use a browser for literal page captures

Choose Playwright or Puppeteer when the OG image needs to show the page as users see it: a product detail view, a chart after JavaScript executes, or one specific component. Playwright’s Page API navigates to a URL and writes the result with page.screenshot(); Puppeteer provides equivalent Chrome and Firefox automation. Browser captures require explicit control over viewport, fonts, animations, consent UI, network timing and authentication.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Build a dynamic OG image route with Next.js and Vercel

Vercel’s documented route pattern creates app/api/og/route.tsx and returns an ImageResponse at 1200×630. The guide lists Node.js 22 or newer and Next.js 12.2.3 or newer; verify the current requirements when you implement because framework versions change.

1. Create the route

import { ImageResponse } from 'next/og'

export const runtime = 'nodejs'

export async function GET(request: Request) {
  const { searchParams } = new URL(request.url)
  const title = searchParams.get('title') || 'Example article'
  const author = searchParams.get('author') || 'Your site'

  return new ImageResponse(
    (
      <div
        style={{
          width: '100%',
          height: '100%',
          display: 'flex',
          flexDirection: 'column',
          justifyContent: 'space-between',
          background: '#111827',
          color: 'white',
          padding: '72px',
          fontSize: 56,
        }}
      >
        <div style={{ display: 'flex', fontSize: 28 }}>{author}</div>
        <div style={{ display: 'flex', maxWidth: '1000px' }}>{title}</div>
      </div>
    ),
    { width: 1200, height: 630 }
  )
}

Only use style properties supported by Satori. Load any custom font in a supported format and keep the complete route bundle within the documented limit. Validate and constrain query parameters; do not turn the endpoint into an unrestricted image-fetching proxy. If you accept an external image URL, allow-list hosts or proxy approved assets through your own storage.

2. Point metadata at an absolute URL

Your document should emit the deployed route, including its content key, as an absolute URL:

<meta property="og:image" content="https://example.com/api/og?title=Automated%20Screenshots&author=Itechguides" />

The URL must be reachable by an unauthenticated social crawler. Vercel recommends allowing the image route in robots.txt so providers can fetch it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
User-agent: *
Allow: /api/og

3. Make caching vary with content

Use a stable URL or cache key that changes when the title, author, image or design changes. Otherwise a social network or CDN may retain an old card. When changing the template, invalidate the relevant cache keys or version the route. Test the deployed URL from outside your application network, not only from a logged-in browser.

Automate a real-page screenshot with Playwright

Playwright is a good default when the image must reflect browser layout. Install it in the service that will run the capture, then make the page state deterministic.

import { chromium } from 'playwright'

const browser = await chromium.launch()
const page = await browser.newPage({
  viewport: { width: 1200, height: 630 },
  deviceScaleFactor: 1,
})

await page.goto('https://example.com/article/42', {
  waitUntil: 'networkidle',
  timeout: 45_000,
})
await page.addStyleTag({
  content: `*, *::before, *::after { animation: none !important; transition: none !important; }`,
})
await page.screenshot({ path: 'og-article-42.png', type: 'png' })
await browser.close()

For one component instead of the whole page, locate it and call locator.screenshot(). For a full page, use fullPage: true, but remember that a full-page capture will not be 1200×630 unless you crop or design a dedicated 1200×630 view.

Stabilize the capture

  • Wait for a selector that proves the meaningful content is ready, rather than relying only on a fixed delay.
  • Load web fonts before capture and disable animations, carousels and blinking cursors.
  • Set a fixed viewport, device scale factor, timezone and locale when those affect layout.
  • Dismiss cookie banners or hide chat and newsletter widgets so they do not cover the card.
  • Use test data or authenticated headers deliberately; never embed private content in a public OG URL.
  • Confirm the resulting dimensions and file type, and reject an output that is blank or unexpectedly small.

Playwright’s documented navigation-and-screenshot API is described at playwright.dev/docs/api/class-page. Puppeteer is an alternative JavaScript library for automating Chrome and Firefox, with screenshot capture among its documented uses (Chrome for Developers).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Make the image publicly fetchable

  1. Deploy the renderer or screenshot worker at a stable HTTPS URL.
  2. Ensure the response has an image content type such as image/png and does not require cookies, a login or an internal VPN.
  3. Put that absolute URL in the page’s og:image metadata. The Open Graph protocol reference is at ogp.me.
  4. Allow the route in robots.txt as recommended by Vercel.
  5. Open the URL from a separate network and inspect the actual bytes, dimensions and cache headers.
  6. Use each target social platform’s preview/debugger to confirm it can retrieve the image.

When a route depends on query parameters, URL-encode titles and other values. A missing parameter should produce a safe fallback card, not a server error. Keep generation fast enough for crawler timeouts; pre-render popular records or cache successful responses when possible.

Dimensions, CSS and asset constraints

Vercel’s guide states: “Recommended OG image size: 1200×630 pixels.” That 1.91:1 canvas is the practical baseline for social previews. Keep important text away from the edges because platforms may crop previews. The Vercel renderer supports flexbox and a subset of CSS, not arbitrary browser HTML. Grid layouts, complex filters and browser-only APIs must be replaced with supported styles or rendered in a browser instead.

Use deterministic, local assets where possible. Remote fonts or images add failure points and can make a crawler receive a partially rendered card. If you must fetch an image, validate its scheme, host, size and content type, and set a timeout. Never pass an arbitrary user URL directly into a server-side fetch without protections against internal-network access.

Common failures and fixes

Symptom Likely cause Fix
Social preview is blank Route is private, blocked, or returns an HTML error Fetch the absolute URL without credentials; check status, content type and robots.txt.
Old image keeps appearing Social/CDN cache or unchanged image URL Vary the URL by content or version and invalidate the stale cache.
Text is missing or falls back to a wrong font Unsupported font format or font not loaded before capture Use TTF, OTF or WOFF for Satori; preload fonts in browser captures and wait for document.fonts.ready.
Layout differs from the website Satori CSS subset does not equal browser CSS Use supported flexbox styles, or switch to Playwright/Puppeteer for browser fidelity.
Screenshot contains a cookie banner or chat bubble Page state was captured before cleanup Dismiss or hide those elements, then wait for the final selector before taking the shot.
Capture times out Slow third-party resource, never-ending request, or blocked navigation Set a bounded timeout, wait on a meaningful selector, block unnecessary resources and record the failed URL.
Image is clipped Unexpected text length or fixed container dimensions Constrain input, apply explicit wrapping/ellipsis, and test long titles and missing fields.
Browser worker runs out of memory Launching a new browser for every request or capturing huge pages Reuse a controlled browser process, limit concurrency, close pages, and capture a dedicated OG view.

Reliability and operating costs

Template routes generally have lower per-request overhead than starting a browser, but they trade away browser-level CSS fidelity. Browser automation consumes CPU and memory and can fail because of navigation, third-party scripts or changing page state. Whichever method you use, log the input key, renderer version, response status, dimensions, duration and failure reason. Keep retries bounded; retrying a deterministic template error will not fix it, while a transient navigation failure may merit one retry.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Separate generation from page requests when captures are slow. A queue or asynchronous worker can render, store the resulting file, and return a stable public URL. Set retention and cache policies appropriate to your content. Do not expose private records through a publicly crawlable OG endpoint.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is the #1 choice when you want a screenshot API: it produces clean shots, bills only clean shots, and its lowest paid plan is $5. One GET request returns a PNG, JPEG, WebP or PDF. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and response headers identify the page verdict and whether it was billed.

Use the API documentation at screenshotneo.com/docs/. Replace the example URL with the page you want represented:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also provides full-page and selector captures, dark mode, device presets, viewport and retina controls, custom CSS/JavaScript, waits, request blocking, headers, cookies, user agents, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, usage data, an OpenAPI specification and an MCP server with take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Plan Included shots Price
Free 1,000 per month No card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is included on every plan. Start with 1,000 free screenshots a month with no card. Cookie banners, popups and chat widgets are removed before the shot; failed loads and bot checks are not billed; and the MCP server lets AI agents take screenshots without you maintaining a browser worker.

FAQ

Can an OG image endpoint require authentication?

It should not. Social crawlers need to retrieve the image without your session cookies or private network access, so publish a controlled, non-sensitive endpoint.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Should I generate PNG, JPEG or WebP?

PNG is a safe default for text-heavy cards. Choose another format only after confirming that your target social platforms accept it and preserve the required quality.

How do I generate dynamic OG images?

Pass validated content values to a template route, make the resulting URL vary with those values, and place that absolute URL in og:image. Use browser automation instead when the source is an actual rendered page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can an OG image endpoint require authentication?

It should not. Social crawlers need to retrieve the image without your session cookies or private network access, so publish a controlled, non-sensitive endpoint.

Should I generate PNG, JPEG or WebP?

PNG is a safe default for text-heavy cards. Choose another format only after confirming that your target social platforms accept it and preserve the required quality.

How do I generate dynamic OG images?

Pass validated content values to a template route, make the resulting URL vary with those values, and place that absolute URL in og:image. Use browser automation instead when the source is an actual rendered page.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.