Appearance
Install
Package install
Choose your package manager:
bash
# npm
npm install @browserbasehq/stagehand
# pnpm (recommended)
pnpm add @browserbasehq/stagehand
# yarn
yarn add @browserbasehq/stagehand
# bun (supported, but cannot use Playwright runner)
bun add @browserbasehq/stagehandScaffold a new project (recommended for first-time setup)
bash
npx create-browser-app
cd my-stagehand-app
cp .env.example .envThis scaffolds a project with sensible defaults, example code, and a ready-to-fill .env file.
Prerequisites
- Node.js (primary runtime; Bun is supported as long as you do not use the Playwright runner)
- Local execution: Chrome must be installed on the machine
- Cloud execution: No local Chrome needed; a Browserbase account and API key are required
Environment variables
Stagehand does not auto-load .env files. Add these to your environment or load them manually with dotenv:
bash
OPENAI_API_KEY=your_openai_api_key
BROWSERBASE_API_KEY=your_browserbase_api_key
BROWSERBASE_PROJECT_ID=your_browserbase_project_idInstall dotenv if loading from a file:
bash
npm install dotenvInitialize at the top of your entry file:
typescript
import dotenv from "dotenv";
dotenv.config({ path: ".env" });Python alternative
A Python version is available at https://github.com/browserbase/stagehand-python.