Get started (46)

Last updated Oct 15, 2026 Cloudflare Browser Run (formerly Browser Rendering) allows you to programmatically control a headless browser, enabling you to do things like take screenshots, generate PDFs, and perform automated browser tasks. This guide will help you choose the right integration method and get you started with your first project.

Browser Run offers two categories of integration methods:

  • Quick Actions: Simple, stateless browser tasks like screenshots, PDFs, and scraping. No code deployment needed.
  • Browser Sessions: Direct browser control via Puppeteer, Playwright, CDP, or Stagehand. Deploy within Cloudflare Workers or connect from any environment via CDP.
Use case Recommended Why
Simple screenshot, PDF, or scrape Quick Actions No code deployment; single HTTP request
Browser automation Playwright, Puppeteer, or CDP Full browser control with scripting
Porting existing scripts Puppeteer, Playwright, or CDP Minimal code changes from standard libraries
AI-powered data extraction JSON endpoint Structured data via natural language prompts
Site-wide crawling Crawl endpoint Multi-page content extraction with async results
AI agent browsing Playwright MCP or CDP with MCP clients LLMs control browsers via MCP
Resilient scraping Stagehand AI finds elements by intent, not selectors
Direct browser control from any environment CDP WebSocket access from local machines, CI/CD, or external servers

Quick Actions

Quick Actions can be used via the REST API or directly from a Cloudflare Worker using a browser binding.

Prerequisites

Example: Take a screenshot

curl -X POST 'https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-rendering/screenshot' \
  -H 'Authorization: Bearer <apiToken>' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://example.com"
  }' \
  --output "screenshot.png"

Prerequisites

Example: Take a screenshot from a Worker

1. Create a Worker project

Create a new Worker project named browser-quick-action by running:

npmyarnpnpm

npm create cloudflare@latest -- browser-quick-action
yarn create cloudflare browser-quick-action
pnpm create cloudflare@latest browser-quick-action

For setup, select the following options:

  • For What would you like to start with?, choose Hello World example.
  • For Which template would you like to use?, choose Worker only.
  • For Which language do you want to use?, choose TypeScript.
  • For Do you want to use git for version control?, choose Yes.
  • For Do you want to add an AGENTS.md file to help AI coding tools understand Cloudflare APIs?, choose Yes.
  • For Do you want to deploy your application?, choose No (we will be making some changes before deploying).

2. Configure the browser binding

Update your Wrangler configuration file with a browser binding:

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "name": "browser-quick-action",
  "main": "src/index.ts",
  "upload_source_maps": true,
  // Set this to today's date
  "compatibility_date": "2026-10-27",
  "browser": {
    "binding": "BROWSER"
  }
}
name = "browser-quick-action"
main = "src/index.ts"
upload_source_maps = true
# Set this to today's date
compatibility_date = "2026-10-27"

[browser]
binding = "BROWSER"

Caution

Using the .quickAction() method requires a compatibility_date of 2026-03-24 or later.

3. Write the Worker code

Replace the contents of src/index.ts with the following:

export default {
    async fetch(request, env) {
        return await env.BROWSER.quickAction("screenshot", {
            url: "https://example.com",
        });
    },
};
interface Env {
    BROWSER: BrowserRun;
}

export default {
    async fetch(request, env): Promise<Response> {
        return await env.BROWSER.quickAction("screenshot", {
            url: "https://example.com",
        });
    },
} satisfies ExportedHandler<Env>;

This Worker uses the browser binding to take a screenshot of example.com and returns the image directly in the response.

4. Test

Run npx wrangler dev --remote to test your Worker locally.

Use real headless browser during local development

To interact with a real headless browser during local development, set "remote" : true in the Browser binding configuration. Learn more in our remote bindings documentation.

Visit your local URL to see the screenshot.

5. Deploy

Run npx wrangler deploy to deploy your Worker to the Cloudflare global network.

Other Quick Actions endpoints include:

Check out the full list of Quick Actions endpoints.

Browser Sessions

Browser Sessions give you full control over a headless browser. You can connect from anywhere using the REST API, or from a Cloudflare Worker using a browser binding.

Prerequisites

Create a browser session

A single API call gives you a live browser session you can see and interact with:

curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/browser-rendering/devtools/browser?keep_alive=600000&targets=true" \
    --request POST \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"

Responsejson

{
    "sessionId": "1909cef7-23e8-4394-bc31-27404bf4348f",
    "targets": [
        {
            "devtoolsFrontendUrl": "https://live.browser.run/ui/inspector?wss=..."
        }
    ]
}

Copy the devtoolsFrontendUrl and open it in your browser. You now have a real browser session running on Cloudflare that you can interact with directly: enter a URL, click around, and inspect the page.

You can drive browser sessions programmatically using CDP, Puppeteer, or Playwright from any environment. Browser sessions also support:

  • Live View: See and interact with a remote session in real time, useful for debugging automation scripts or monitoring browser activity.
  • Session Recording: Record browser sessions for playback, so you can review what happened during an automation run.
  • Human in the Loop: Pause automation and hand control to a human for tasks that require manual intervention, like solving CAPTCHAs or completing login flows.

Prerequisites

  1. Sign up for a Cloudflare account ↗︎.
  2. Install Node.js ↗︎.

<details>

<summary>

Node.js version manager

</summary>

Use <a href="https://viteplus.dev/guide/env">Vite+ (<code>vp env</code>) ↗︎</a> to install and manage Node.js versions.

For supported Node.js versions, refer to the <a href="https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler">Wrangler system requirements</a>.

</details>

Example: Navigate to a URL, take a screenshot, and store in KV

1. Create a Worker project

Cloudflare Workers provides a serverless execution environment that allows you to create new applications or augment existing ones without configuring or maintaining infrastructure. Your Worker application is a container to interact with a headless browser to do actions, such as taking screenshots.