This guide will walk you through setting up your Hyperbrowser account, launching your first cloud browser session, and controlling it programmatically using Puppeteer in Node.js. In just a few minutes, you’ll be automating browsers in the cloud.

Want to jump right in? Skip to our example projects.

Using a different stack? Check out our guides for Playwright, Python SDK, or view the API Reference.

Initial Setup

1. Create a Hyperbrowser Account

  • Sign up for a free account at app.hyperbrowser.ai
  • The free tier includes browser hours to get you started
  • No credit card required

2. Get Your API Key

  • After signing up, navigate to Settings > API Keys in the dashboard
  • Create an API key and store it securely - you won’t be able to view it again
  • Keep this key private and never commit it to version control

3. Set Up Environment Variables

  • Create a .env file in your project root:
  • Add your API key as HYPERBROWSER_API_KEY
HYPERBROWSER_API_KEY=your_api_key_here

Install the Node.js SDK

npm install @hyperbrowser/sdk

Create a Session

import Hyperbrowser from "hyperbrowser";
import dotenv from "dotenv";

dotenv.config();

const client = new Hyperbrowser({
  apiKey: process.env.HYPERBROWSER_API_KEY,
});

(async () => {
  const session = await client.createSession();

  // Session created successfully and ready to use
  console.log("Session created:", session);

  // Once done, you can stop the session
  await client.stopSession(session.id);

  console.log("Session stopped:", session.id);
})().catch((error) => console.error(error.message));

Connecting to the Session

You can connect to the session using automation libraries like Puppeteer or Playwright.

Puppeteer

import { connect } from "puppeteer-core";
import Hyperbrowser from "@hyperbrowser/sdk";
import dotenv from "dotenv";

dotenv.config();

const client = new Hyperbrowser({
  apiKey: process.env.HYPERBROWSER_API_KEY,
});

(async () => {
  const session = await client.createSession();

  const browser = await connect({
    browserWSEndpoint: session.wsEndpoint,
    defaultViewport: null,
  });

  // Create a new page
  const [page] = await browser.pages();

  // Navigate to a website
  console.log("Navigating to Hacker News...");
  await page.goto("https://news.ycombinator.com/");
  const pageTitle = await page.title();
  console.log("Page title:", pageTitle);

  await page.close();
  await browser.close();
  console.log("Session completed!");
})().catch((error) => console.error(error.message));

You have now successfully created your first Hyperbrowser session and connected to it using Puppeteer. Check out our other guides for more examples on how to Hyperbrowser.