Start your first Session with Playwright
Get started with a Playwright Node.js template
Clone this GitHub repo to start using Browserbase with Playwright in Node.
Get started with a Playwright Python template
Clone this GitHub repo to start using Browserbase with Playwright in Python.
Get your API Key
Go over the Dashboard’s Settings tab:
Then copy your API Key directly from the input and update your .env
by adding the BROWSERBASE_API_KEY
entry
Alternatively, you can temporarily set the environment variable for a single bash command by prefixing it with BROWSERBASE_API_KEY=<your_api_key>
in your terminal.
Install Playwright
npm i playwright-core
Update your code or clone a template
Running your existing code with Browserbase only requires a few line changes:
import { chromium } from "playwright-core";
(async () => {
const browser = await chromium.connectOverCDP(
`wss://connect.browserbase.com?apiKey=${process.env.BROWSERBASE_API_KEY}`
);
// Getting the default context to ensure the sessions are recorded.
const defaultContext = browser.contexts()[0];
const page = defaultContext.pages()[0];
await page.goto("https://browserbase.com/");
await page.close();
await browser.close();
})().catch((error) => console.error(error.message));
BROWSERBASE_API_KEY
environment variable to the value you copied from the Dashboard.Inspect the completed Session
You can find all the recent sessions on the Dashboard’s Overview, along with essential metrics:
Select your Session to inspect it with the Session Inspector.
Start building
Was this page helpful?