For AI agents: a documentation index is available at /llms.txt
Skip to main content

Quick Start

Connect to Browserless using either Puppeteer or Playwright through Chrome's DevTools Protocol (CDP) using websockets. This is the primary and recommended way to connect to Browserless, as it provides a stable and reliable connection.

Follow these steps to get started with Browserless:

  1. Get Your API Token

    API Key Dashboard

  2. Install Library

    Choose your preferred automation library and install it:

    npm install puppeteer-core
  3. Run Your First Example

    Here's a complete working example:

    import puppeteer from "puppeteer-core";

    const TOKEN = "YOUR_API_TOKEN_HERE"; // Replace with your actual token

    async function getPageTitle() {
    // Connect to Browserless using WebSocket endpoint
    const browser = await puppeteer.connect({
    browserWSEndpoint: `wss://production-sfo.browserless.io?token=${TOKEN}`,
    });

    const page = await browser.newPage();

    // Navigate to the target website
    await page.goto("https://www.example.com/");

    // Get the page title
    const title = await page.title();
    console.log(`The page's title is: ${title}`);

    // Clean up resources
    await browser.close();
    }

    getPageTitle().catch(console.error);

    Output

    The page's title is: Example Domain
tip

The examples above connect to the US West region (production-sfo). Browserless is also available in Europe. See Regional Endpoints to choose the region closest to your target sites.

Next Steps

Explore these key features to enhance your browser automation:

Frequently Asked Questions

How do I connect Puppeteer to Browserless?

Replace your local browser launch with a WebSocket connection to Browserless. Use puppeteer.connect() with the Browserless WebSocket URL and your API token as a query parameter.

Does Browserless support Playwright?

Yes. Connect Playwright to Browserless using browserType.connect() with the Browserless WebSocket URL. Both Chromium and Firefox browsers are supported for Playwright connections.

Do I need to change my existing automation code?

Minimal changes are needed. Replace your browser launch call with a connect call pointing to Browserless. The rest of your Puppeteer or Playwright code runs unchanged against the remote browser.

Is there a free tier to try Browserless?

Yes. Sign up at browserless.io for a free account that includes a limited number of browser sessions per month. This lets you test your automation code against managed browsers before scaling up.