Launch your first cloud browser.
Connect Playwright to Browserherd, open a page, and close the session when your work is complete. The same connection pattern works from local development, a worker, or CI.
Create an API key
Open the Browserherd dashboard, select your project, and choose API key. Copy the key and store it in an environment variable.
.ENVBROWSERHERD_API_KEY=bh_live_your_project_keyInstall Playwright Core
Use
playwright-corewhen connecting to an existing cloud browser. It does not download a local browser binary.TERMINALnpm install playwright-coreConnect to Browserherd
Build the WebSocket endpoint from your API key and session options, then connect over the Chrome DevTools Protocol.
QUICKSTART.JSimport { chromium } from "playwright-core"; const query = new URLSearchParams({ token: process.env.BROWSERHERD_API_KEY, sessionName: "quickstart", sessionTTL: "900", sessionRecording: "true", region: "us-east-1" }); const endpoint = `wss://connect.browserherd.com?${query}`; const browser = await chromium.connectOverCDP(endpoint); const context = browser.contexts()[0]; const page = await context.newPage(); await page.goto("https://example.com", { waitUntil: "domcontentloaded" }); console.log(await page.title()); await browser.close();Closing the browser ends the cloud session and stops usage.Run the script
TERMINALnode quickstart.jsThe terminal prints
Example Domain. The completed session also appears in Dashboard → History with its duration, status, region, and recording.
Connection parameters
Add parameters to the WebSocket query string to configure each browser session.
| Parameter | Type | Description |
|---|---|---|
| token required | string | Your Browserherd project API key. |
| sessionTTL | number | Maximum session duration in seconds. Defaults to 900. The browser closes automatically when the TTL is reached. |
| sessionName | string | A searchable name shown in session history. |
| sessionRecording | boolean | Records the session for replay after it completes. Defaults to false. |
| region | string | Execution region, such as us-east-1, us-west-1, eu-west-1, or ap-southeast-1. |
| profileId | string | Optional persistent profile whose cookies and browser state should be attached. |
| viewport | string | Browser viewport formatted as WIDTHxHEIGHT, for example 1440x900. |
Complete WebSocket URL
wss://connect.browserherd.com?token=YOUR_API_KEY&sessionTTL=900&sessionName=quickstart&sessionRecording=true®ion=us-east-1&viewport=1440x900WSS