Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk7 min

How to Generate Website Thumbnails with a Cloudflare Worker

A documentation-based guide to generating website thumbnails in a Cloudflare Worker with Browser Run, including binding setup, capture options, readiness, limits, and errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Cloudflare Browser Run’s screenshot Quick Action from a Worker binding: validate the requested URL, call env.BROWSER.quickAction("screenshot", options), and return the image response. This approach renders the page’s HTML and JavaScript before capture, so you can produce thumbnails without running a separate browser service yourself.

Use a Worker binding for a Worker-hosted thumbnail endpoint

Cloudflare’s current documentation calls the service Browser Run; it was formerly called Browser Rendering. For a Worker that generates thumbnails, the direct path is a Browser Run binding named BROWSER. The Worker calls env.BROWSER.quickAction("screenshot", options) and returns the response.

The screenshot action accepts a URL or HTML. A URL is the natural input for a website-thumbnail endpoint. Use HTML instead when you want to render a custom preview card rather than capture an existing page. The separate REST endpoint is useful for integrations outside Workers, but it requires an API token with Browser Rendering edit permission; a binding keeps that token out of the Worker’s request code. See Cloudflare Browser Run documentation.

Configure the browser binding

Add a browser binding named BROWSER in wrangler.toml and use a Worker compatibility date of 2026-03-24 or later, which is required for quickAction(). Cloudflare’s documentation-based configuration is:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
name = "website-thumbnails"
main = "src/index.js"
compatibility_date = "2026-03-24"

[browser]
binding = "BROWSER"

For local development, this method is not supported in wrangler dev local mode. Run wrangler dev --remote, or set remote = true on the browser binding as documented by Cloudflare. A local-mode test that fails to resolve the binding does not establish that the deployed Worker configuration is wrong.

Build a small endpoint with URL validation

Because the endpoint accepts a URL from its caller, reject malformed URLs and unsupported schemes before asking the browser to open them. The example below only accepts HTTP and HTTPS URLs, returns a 400 for invalid input, and passes the Quick Action response through to the caller. It uses a fixed viewport suitable for a thumbnail and asks for a rendered page before capture.

export default {
  async fetch(request, env) {
    const requestUrl = new URL(request.url);
    const target = requestUrl.searchParams.get("url");

    if (!target) {
      return new Response("Missing required url parameter", { status: 400 });
    }

    let parsed;
    try {
      parsed = new URL(target);
    } catch {
      return new Response("Invalid URL", { status: 400 });
    }

    if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
      return new Response("Only http and https URLs are supported", { status: 400 });
    }

    try {
      const result = await env.BROWSER.quickAction("screenshot", {
        url: parsed.href,
        viewport: { width: 1200, height: 630 },
        gotoOptions: { waitUntil: "networkidle2" },
        screenshotOptions: { type: "jpeg", quality: 82 }
      });
      return result;
    } catch (error) {
      return new Response("Screenshot capture failed", { status: 502 });
    }
  }
};

This is a minimal endpoint, not a complete public-service security policy. If it will be exposed to untrusted callers, add access control and request-rate controls appropriate to your application, and consider which destinations it should be allowed to fetch. Do not treat a caller-supplied URL as trusted input.

Rank #2
Free Fling File Transfer Software for Windows [PC Download]
  • Intuitive interface of a conventional FTP client
  • Easy and Reliable FTP Site Maintenance.
  • FTP Automation and Synchronization

Choose framing and output intentionally

The browser viewport defines the visible browser window. A 1200 by 630 viewport gives a landscape preview, while a different width and height may suit a card or dashboard. Cloudflare documents a default viewport of 1920 by 1080 and a default device scale factor of 1; specify dimensions rather than relying on defaults when consistent thumbnail framing matters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Viewport capture: captures what fits in the browser window and is the usual choice for a thumbnail.
  • Full-page capture: use screenshotOptions.fullPage when the thumbnail should represent the full document rather than its opening viewport.
  • Clipped capture: use the documented clip option to capture a rectangle.
  • Element capture: use the documented selector option when the desired preview is a particular page element.

Check the Quick Action output type expected by your caller before choosing encoding options. Quality is incompatible with PNG; choose a supported lossy format such as JPEG if you need to set quality. At device scale factor 1, a large viewport can appear soft when displayed at higher resolution; increasing deviceScaleFactor can improve pixel density, at the cost of a larger image.

Wait for the page content you actually need

A page-load event can happen before a JavaScript-heavy application or single-page application has painted useful content. Cloudflare documents gotoOptions.waitUntil values networkidle0 and networkidle2 for waiting until network activity settles. These are convenient when the page’s readiness condition is unknown, but some sites keep network connections open or poll continuously.

When the thumbnail depends on a known component, a selector-based waitForSelector is a more targeted readiness signal and can be faster than waiting for all network activity to stop. Select a stable, visible element that indicates the content is ready. Avoid a selector that only appears after a user interaction your capture never performs.

Binding or REST, URL or HTML

Choice Use it when Trade-off
Worker binding The capture is part of a Cloudflare Worker request. Calls env.BROWSER.quickAction() directly; requires the binding and compatibility date, and remote mode for local development.
REST screenshot endpoint An external service or script needs to request a capture. Uses POST https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-run/screenshot and requires an API token with Browser Rendering edit permission.
URL input You want to capture an existing website. The browser must load and render that destination before taking the image.
HTML input You want to render a custom preview, rather than reproduce a live page. You supply the content to be rendered instead of relying on the target site’s current page.

Cloudflare’s API reference also describes a related snapshot endpoint that can return HTML and a screenshot together, with viewport, full-page, clipping, waiting, and output-format controls. For a thumbnail-only endpoint, the screenshot Quick Action is the narrower fit; snapshot is relevant when the application also needs extracted page content. See the screenshot API reference.

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

Usage limits, latency, and reliability

Cloudflare’s limits documentation, checked October 3, 2026, lists these Browser Run limits. They are service allowances and rate limits, not throughput benchmarks or guarantees:

Plan Browser Run limit listed by Cloudflare
Free 10 minutes of Browser Run usage per day; one Quick Actions request every 10 seconds.
Workers Paid 30 Quick Actions requests per second by default; no browser-hours cap.

Cloudflare documents a 60-second default browser timeout. A slow destination can therefore fail even when the Worker code is valid. Check the current Browser Run limits and pricing before estimating production capacity, because service limits and pricing can change.

Handle failures as normal outcomes: return a controlled error instead of leaking internal exception details, and have callers retry selectively rather than retrying every failed request immediately. Retries can add browser time and encounter rate limits; an exponential backoff and a bounded retry count are safer than a tight loop.

Troubleshooting common failures

  • env.BROWSER is unavailable: confirm the binding name is exactly BROWSER and configured for the Worker. For local testing, switch to wrangler dev --remote or use remote = true on the browser binding.
  • quickAction() is not available: set the Worker compatibility date to 2026-03-24 or later.
  • The screenshot is blank or missing app content: the page may still be rendering client-side content after the default navigation event. Try networkidle0, networkidle2, or a selector that marks the specific content as ready.
  • The capture times out: the target may load slowly or never reach the chosen readiness condition. Use a more targeted selector when appropriate, and account for Cloudflare’s documented 60-second default timeout.
  • The endpoint returns HTTP 429: Cloudflare documents 429 responses for rate or browser-time limits. Reduce request rate, stay within the applicable plan allowance, and check the current limits page.
  • The image looks soft: increase deviceScaleFactor when you need more pixel density, and verify that the returned image dimensions fit how the thumbnail will be displayed.
  • Quality settings are rejected: do not combine quality with PNG; use JPEG or another supported format that accepts quality.
  • A bot-protected site refuses the capture: changing the user agent is not a bypass. Cloudflare says Browser Run requests remain identifiable as bots; do not use user-agent customization to imply otherwise or to evade a destination’s controls.
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 a screenshot API with a one-request URL flow. Its documented positioning is useful when you do not want to configure a browser binding: cookie banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, and failed loads are never billed; and an MCP server provides screenshot tools for AI agents. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. See the ScreenshotNeo API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Frequently Asked Questions

Can a Cloudflare Worker capture a full page instead of the visible viewport?

Yes. The screenshot Quick Action documents screenshotOptions.fullPage for full-page capture; use it when the image should represent the full document rather than the viewport.

Does changing the browser user agent get around a website’s bot protection?

No. Cloudflare says Browser Run requests remain identifiable as bots, so a user-agent override should not be treated as a way to bypass a destination’s access controls.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.