- Browserbase - Cloud-managed browser infrastructure optimized for production web automation at scale
- Local - Run browsers directly on your machine for development and debugging
Browserbase Environment
Browserbase provides managed cloud browser infrastructure optimized for web automation at scale. It offers advanced features like stealth mode, proxy support, and persistent contexts.Browserbase
Discover the power of cloud-managed browser infrastructure with Browserbase.
Environment Variables
Before getting started, set up the required environment variables:Get your API key and Project ID from the Browserbase Dashboard
Using Stagehand with Browserbase
Basic Setup
The simplest way to get started is with default settings:Advanced Configuration
Configure browser settings, proxy support, and other session parameters:Advanced Browserbase Configuration Example
Advanced Browserbase Configuration Example
Initialization Result
After callingstagehand.init()
, the method returns configuration information about the initialized session:
debugUrl
debugUrl
Open the Browserbase session live view to include a human-in-the-loop.
sessionUrl
sessionUrl
Open the session replay to see the full session recording.
sessionId
sessionId
Unique identifier for the Browserbase session. This is used to identify the session in the Browserbase dashboard and to connect to the session.
Alternative: Browserbase SDK
If you prefer to manage sessions directly, you can use the Browserbase SDK:Connecting to an Existing Session
Connect to a previously created Browserbase session using its session ID:Local Environment
The local environment runs browsers directly on your machine, providing full control over browser instances and configurations. Ideal for development, debugging, and scenarios requiring custom browser setups.Environment Comparison
Feature | Browserbase | Local |
---|---|---|
Scalability | High (cloud-managed) | Limited (local resources) |
Stealth Features | Advanced fingerprinting | Basic stealth |
Proxy Support | Built-in residential proxies | Manual configuration |
Session Persistence | Cloud context storage | File-based user data |
Geographic Distribution | Multi-region deployment | Single machine |
Debugging | Session recordings & logs | Direct DevTools access |
Setup Complexity | Environment variables only | Browser installation required |
Cost | Usage-based pricing | Infrastructure & maintenance |
Best For | Production, scale, compliance | Development, debugging |
Basic Local Setup
Advanced Local Configuration
Customize browser launch options for local development:Connecting to your local browser
Connect to your existing local Chrome/Chromium browser instead of launching a new one. This lets you automate your normal browser with all your existing tabs, extensions and settings.Troubleshooting
Common Issues
Browserbase Authentication Errors
Browserbase Authentication Errors
- Verify your
BROWSERBASE_API_KEY
andBROWSERBASE_PROJECT_ID
are set correctly - Check that your API key has the necessary permissions
- Ensure your Browserbase account has sufficient credits
Local Browser Launch Failures
Local Browser Launch Failures
- Install Chrome or Chromium on your system
- Set the correct
executablePath
for your Chrome installation - Check that required dependencies are installed (Linux:
libnss3-dev libatk-bridge2.0-dev libgtk-3-dev libxss1 libasound2
)
Session Timeout Issues
Session Timeout Issues
- Increase session timeout in
browserbaseSessionCreateParams.timeout
- Use
keepAlive: true
for long-running sessions - Monitor session usage to avoid unexpected terminations