Stealth Mode

Stealth mode helps you avoid detection by anti-bot systems. It randomizes browser fingerprints and can be configured when creating a new session via the API. Options include:

  • Devices - Specify mobile or desktop device profiles

  • Locales - Set browser locale (e.g. en-US, fr-FR)

  • Operating Systems - Simulate different OSes like Android, iOS, Windows, macOS, Linux

  • Screen Size - Specify viewport dimensions to emulate different devices

  • User Agents - Rotate user agent strings

To enable stealth mode and other stealth configurations, you can set the desired options in the session creation params when creating a session.

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

config();

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

const main = async () => {
  const session = await client.sessions.create({
    useStealth: true,
    operatingSystems: ["macos"],
    device: ["desktop"],
    locales: ["en"],
    screen: {
      width: 1920,
      height: 1080,
    },
  });

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

    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 1:", pageTitle);
    await page.evaluate(() => {
      console.log("Page 1:", document.title);
    });
  } catch (err) {
    console.error(`Encountered error: ${err}`);
  } finally {
    await client.sessions.stop(session.id);
  }
};

main();

To see all the available options, check out the Create Session API Reference

Last updated