Skip to content
Getting started

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.

  1. 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.

    .ENV
    BROWSERHERD_API_KEY=bh_live_your_project_key
  2. Install Playwright Core

    Use playwright-core when connecting to an existing cloud browser. It does not download a local browser binary.

    TERMINAL
    npm install playwright-core
  3. Connect to Browserherd

    Build the WebSocket endpoint from your API key and session options, then connect over the Chrome DevTools Protocol.

    QUICKSTART.JS
    import { 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.
  4. Run the script

    TERMINAL
    node quickstart.js

    The 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.

ParameterTypeDescription
token requiredstringYour Browserherd project API key.
sessionTTLnumberMaximum session duration in seconds. Defaults to 900. The browser closes automatically when the TTL is reached.
sessionNamestringA searchable name shown in session history.
sessionRecordingbooleanRecords the session for replay after it completes. Defaults to false.
regionstringExecution region, such as us-east-1, us-west-1, eu-west-1, or ap-southeast-1.
profileIdstringOptional persistent profile whose cookies and browser state should be attached.
viewportstringBrowser viewport formatted as WIDTHxHEIGHT, for example 1440x900.

Complete WebSocket URL

wss://connect.browserherd.com?token=YOUR_API_KEY&sessionTTL=900&sessionName=quickstart&sessionRecording=true&region=us-east-1&viewport=1440x900WSS

Next steps