Package Installation
Install Stagehand using your preferred package manager:System Requirements
Node.js Version
Requires Node.js
^20.19.0 or >=22.12.0Package Manager
Supports npm, pnpm (9.15.0+), and yarn
TypeScript
TypeScript 5.8.3+ recommended for type safety
Browser
Chrome/Chromium required for local environment
Dependencies
Stagehand has the following peer dependencies:Quick Start Installation
The fastest way to get started is with the project generator:- Stagehand pre-installed and configured
- Example automation scripts
- Environment variable templates
- TypeScript support
Building from Source
For development or to use the latest features from the main branch:Install Dependencies
The repository uses pnpm workspaces. Make sure you have pnpm installed:
npm install -g pnpmInstalling from a Branch
You can install Stagehand directly from a GitHub branch using gitpkg: In your project’spackage.json:
<branchName> with the branch you want to install from (e.g., main, develop, or a feature branch).
Environment Setup
After installation, configure your environment variables:Option 1: Using Browserbase (Recommended)
For production environments, use Browserbase’s cloud browser infrastructure:.env
Option 2: Local Development
For local development and testing:.env
Configuration File Template
Create a.env.example file in your project:
.env.example
Supported AI Models
Stagehand supports multiple AI model providers:OpenAI
GPT-4, GPT-4 Turbo, GPT-5
Anthropic
Claude Sonnet, Claude Opus
Gemini 2.0 Flash, Gemini Pro
Others
Groq, Azure OpenAI, and custom endpoints
Browser Environment Options
Stagehand can run in different browser environments:Browserbase (Production)
- No local Chrome installation needed
- Scalable cloud infrastructure
- Built-in debugging and observability
- Optimized for production workloads
Local (Development)
- Fast iteration during development
- No cloud costs
- Full control over browser instance
- Works offline
Optional Dependencies
Stagehand includes several optional dependencies for additional functionality:Browser Automation Libraries
Install these if you want to use Stagehand with existing Playwright or Puppeteer code:Additional AI Providers
Install provider-specific packages for enhanced functionality:Verification
Verify your installation by running a simple test:test.ts
Troubleshooting
Node version error
Node version error
If you see an error about Node version, make sure you’re using Node.js Use nvm to manage Node versions:
^20.19.0 or >=22.12.0:Chrome not found (local environment)
Chrome not found (local environment)
If you see “Chrome not found” when using
env: "LOCAL", install Chrome or Chromium:Browserbase connection issues
Browserbase connection issues
If you can’t connect to Browserbase, verify:
- Your API key is correct
- Your project ID is valid
- You have an active Browserbase subscription
TypeScript errors
TypeScript errors
If you encounter TypeScript errors, ensure you have the latest types:And verify your
tsconfig.json includes:Next Steps
Quickstart Guide
Run your first automation in minutes
Configuration
Learn about browser and model configuration
Core Methods
Explore act(), extract(), observe(), and agent()
Examples
View real-world automation examples
Need help? Join our Discord community or open an issue on GitHub.