Add web browsing capabilities to Cloudflare Workers
Integrate Browserbase with Cloudflare Workers
Get your API Key
Go over the Dashboard’s Settings tab:
Then copy your API Key directly from the input and
set the BROWSERBASE_API_KEY
environment variable.
Create a Cloudflare Worker Project
Create a new Cloudflare Worker project if you haven’t already.
Cloudflare Workers currently only support JavaScript and TypeScript.
Using Browserbase with Puppeteer on Cloudflare Workers (Browser Rendering and Pages Functions) requires you to be on Cloudflare’s Paid Plan.
Install Cloudflare's Puppeteer NPM Package
Cloudflare Workers uses their dedicated npm package for Puppeteer.
This is a fork of the original Puppeteer package, but with minimal changes to support Cloudflare Workers.
Configure your `wrangler.toml` file
Below is an example of what your wrangler.toml
file should look like.
You can find your API Key and Project ID by going back to step 1.
Update your Cloudflare Worker to use Browserbase
Running your existing code with Browserbase works the same as using normal Cloudflare Workers, with a few line changes:
Deploy your Cloudflare Worker
Deploy your Cloudflare Worker to Cloudflare:
You should see a URL that looks something like this:
Click on the link and you’ll see the current URL of the page that was rendered.
Was this page helpful?