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.
Playwright is a powerful browser automation framework that works seamlessly with Hyperbrowser sessions. This guide shows you how to connect Playwright to your cloud browser sessions.
Installation
First, install Playwright:
npm install @hyperbrowser/sdk playwright-core dotenv
Basic Connection
Connect Playwright to a Hyperbrowser session:
import { Hyperbrowser } from "@hyperbrowser/sdk" ;
import { chromium } from "playwright-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 ({
acceptCookies: true ,
});
try {
// Connect Playwright
const browser = await chromium . connectOverCDP ( session . wsEndpoint );
const defaultContext = browser . contexts ()[ 0 ];
// Get the default page
const page = defaultContext . 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
Puppeteer Integration Connect with Puppeteer
Session Lifecycle Manage sessions
Stealth Mode Configure anti-detection
Profiles Persist browser state