Skip to content

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/stagehand
bash
npx create-browser-app
cd my-stagehand-app
cp .env.example .env

This 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_id

Install dotenv if loading from a file:

bash
npm install dotenv

Initialize 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.