Once you create a session, you’ll receive a connection URL that you can use with your preferred automation framework. Here’s how to connect using our supported frameworks:
Copy
Ask AI
import { Browserbase } from "@browserbasehq/sdk";const bb = new Browserbase({ apiKey: process.env.BROWSERBASE_API_KEY! });// Create a sessionconst session = await bb.sessions.create({ projectId: process.env.BROWSERBASE_PROJECT_ID});// Connect and automateconst browser = await bb.connect(session.id);
Once connected, use your preferred framework’s APIs to control the browser. Each framework has its own methods for navigation, interaction, and automation.
Integrate the Live View directly into your application to show your users their automated browser sessions in real-time. The Live View enables remote control over the browser, unlocking human-in-the-loop possibilities to handle authentication, captcha, or unexpected errors.
While Browserbase automatically handles session termination when you disconnect, understanding how sessions end is important.For more details about session termination, timeouts, and best practices for managing session lifecycle, see Manage a Browser Session.