Automate browsers with AI
Browserbase is a platform for running headless browsers. If you’re building automations that need to interact with websites, fill out forms, or replicate users actions, Browserbase manages that infrastructure so you don’t have to maintain your own fleet of headless browsers.
It provides a simple API for controlling browsers, useful features for managing browser sessions, and a scalable infrastructure for running them in production.
Resources:
We will automatically sync your Browserbase API Key and Project ID to Vercel for you. Click the "Connect project" button above and select a project for these to be made available to it.
If you haven't connected your Next.js source folder to your Vercel project yet, link it with this command:
vercel linkAfterwards, you can pull your new Browserbase secrets like this:
vercel pullIn your project folder, install the Browserbase Node.js SDK, which will allow you to programatically create and manage browser sessions:
npm install -S @browserbasehq/sdkIn one of your server side scripts, like a route.ts file, add the following code for creating a new browser session:
import { Browserbase } from "@browserbasehq/sdk";
const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY });const session = await bb.sessions.create({ projectId: process.env.BROWSERBASE_PROJECT_ID, // Add configuration options here});The returned session will contain an ID you can use for further interacting with the session. You can find more details about the available configuration options in this guide.
Once connected, use your preferred framework’s APIs to control the browser. Each framework has its own methods for navigation, interaction, and automation.
Select which framework you'd like to explore. Stagehand is our own SDK for automating the web built from the ground up to work seemlessly with Browserbase, but you can use any framework you prefer: