> ## Documentation Index
> Fetch the complete documentation index at: https://hyperbrowser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect with Puppeteer

> Control Hyperbrowser sessions using Puppeteer

Puppeteer is a popular Node.js library for browser automation that integrates seamlessly with Hyperbrowser sessions. This guide shows you how to connect Puppeteer to your cloud browsers.

<Note>
  Puppeteer is a Node.js integration. Python clients should use the
  [Playwright integration](/docs/sessions/playwright); Pyppeteer's WebSocket
  dependency is incompatible with the Hyperbrowser Python SDK.
</Note>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @hyperbrowser/sdk puppeteer-core dotenv
  ```

  ```bash yarn theme={null}
  yarn add @hyperbrowser/sdk puppeteer-core dotenv
  ```
</CodeGroup>

<Note>
  For Node.js, use `puppeteer-core` instead of `puppeteer` since Hyperbrowser provides the
  browser. This saves disk space and installation time.
</Note>

## Basic Connection

Connect Puppeteer to a Hyperbrowser session:

```typescript Node.js theme={null}
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { connect } from "puppeteer-core";
import { config } from "dotenv";

config();

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

async function main() {
  // Create session
  const session = await client.sessions.create();

  try {
    // Connect Puppeteer
    const browser = await connect({
      browserWSEndpoint: session.wsEndpoint,
      defaultViewport: null,
    });
    const defaultContext = browser.defaultBrowserContext();

    // Get or create a page
    const pages = await defaultContext.pages();
    const page = pages[0];

    // Navigate and interact
    await page.goto("https://example.com");
    console.log("Title:", await page.title());
  } catch (err) {
    console.error("Encountered error:", err);
  } finally {
    // Clean up
    await client.sessions.stop(session.id);
  }
}

main().catch(console.error);
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Playwright Integration" icon="code" href="/docs/sessions/playwright">
    Connect with Playwright
  </Card>

  <Card title="Session Lifecycle" icon="rotate" href="/docs/sessions/lifecycle">
    Manage sessions
  </Card>

  <Card title="Stealth Mode" icon="user-secret" href="/docs/sessions/stealth">
    Configure anti-detection
  </Card>

  <Card title="Profiles" icon="user" href="/docs/sessions/profiles">
    Persist browser state
  </Card>
</CardGroup>
