Pular para o conteúdo

Wrangler

Atualizado em Ver como Markdown

Wrangler is a command-line tool for building with Cloudflare developer products.

Use Wrangler to deploy projects that use the Workers Browser Run API.

Install

To install Wrangler, refer to Install and Update Wrangler.

Bindings

Bindings allow your Workers to interact with resources on the Cloudflare developer platform. A browser binding will provide your Worker with an authenticated endpoint to interact with a dedicated Chromium browser instance.

To deploy a Browser Run Worker, you must declare a browser binding in your Worker's Wrangler configuration file.

{
	"$schema": "./node_modules/wrangler/config-schema.json",
	// Top-level configuration
	"name": "browser-rendering",
	"main": "src/index.ts",
	"workers_dev": true,
	"compatibility_flags": ["nodejs_compat_v2"],
	"browser": {
		"binding": "MYBROWSER",
	},
}
"$schema" = "./node_modules/wrangler/config-schema.json"
name = "browser-rendering"
main = "src/index.ts"
workers_dev = true
compatibility_flags = [ "nodejs_compat_v2" ]

[browser]
binding = "MYBROWSER"

After the binding is declared, access the DevTools endpoint using env.MYBROWSER in your Worker code:

const browser = await puppeteer.launch(env.MYBROWSER);

For Puppeteer, Playwright, or CDP-based Workers, run npx wrangler dev to test locally. For Quick Actions via .quickAction(), use npx wrangler dev --remote as noted above.

Headful mode (experimental)

By default, local development runs Chrome in headless mode. To launch Chrome in visible (headful) mode for debugging, set the X_BROWSER_HEADFUL environment variable:

X_BROWSER_HEADFUL=true npx wrangler dev

This opens a browser window on screen so you can watch navigations, interactions, and rendering in real time. Headful mode is for local development only and does not affect deployed Workers. This feature is experimental and may change without notice.