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: