Overview
Stagehand is a TypeScript browser automation framework from Browserbase. It lets you drive a real web browser using a mix of natural language and normal code, so you can describe an action in plain English when you don't know a page's structure and fall back to precise code when you do.
It is aimed at developers who find low-level tools like Selenium, Playwright, or Puppeteer too verbose for unfamiliar pages, but who also find fully autonomous agents too unpredictable for production. Stagehand sits between the two: you choose, action by action, whether AI or code is in control.
As an agent framework for browser use, it adds act(), extract(), and agent() methods on top of a CDP browser engine. It also caches repeatable actions and self-heals when a site changes, so workflows can run without calling an LLM every time.
What it does
- act() runs a single action described in natural language, such as clicking a specific link
- extract() pulls structured data from a page using a Zod schema you define
- agent() executes multi-step tasks autonomously, like navigating to the latest pull request
- Auto-caching replays previously learned actions without LLM inference to save time and tokens
- Self-healing re-involves the AI only when a website changes and a cached action breaks
- Built on a CDP browser engine and works with an LLM provider key plus Browserbase credentials
Getting started
The fastest way to start is the project scaffolder, which sets up a working browser-automation app for you.
Scaffold a new project
Run the create command to generate a starter Stagehand app.
npx create-browser-appAdd your API keys
Stagehand works best with an LLM provider API key and Browserbase credentials. Copy the example env file and fill in your keys.
cp .env.example .env
nano .env # add your API keysDrive the browser
Use act() for single actions, agent() for multi-step tasks, and extract() with a Zod schema for structured data.
const page = stagehand.context.pages()[0];
await page.goto("https://github.com/browserbase");
// Single action
await stagehand.act("click on the stagehand repo");
// Multi-step task
const agent = stagehand.agent();
await agent.execute("Get to the latest PR");
// Structured extraction
const { author, title } = await stagehand.extract(
"extract the author and title of the PR",
z.object({
author: z.string().describe("The username of the PR author"),
title: z.string().describe("The title of the PR"),
}),
);Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Automating web tasks on unfamiliar pages where you can't write selectors in advance
- Extracting structured data from web pages into typed objects with a Zod schema
- Turning AI-driven exploration into repeatable, cached workflows that run without an LLM
- Building production web agents that mix natural-language steps with precise code
How Stagehand compares
Stagehand alongside other open-source computer & browser use tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Browser Use | ★ 105k | A Python library that lets agents control a real browser to read pages and complete tasks online from natural-language instructions. |
| Open Interpreter | ★ 65.9k | A lightweight coding agent that runs code on your own computer to carry out tasks from natural-language requests. |
| UI-TARS Desktop | ★ 38k | ByteDance's multimodal agent stack and desktop app that controls a computer's graphical interface using vision-language models. |
| Stagehand | ★ 23.5k | Control the browser with natural language and code in one TypeScript SDK |
| Skyvern | ★ 22.4k | A tool that uses language models and computer vision to automate browser workflows without writing custom code for each website. |
| Cua | ★ 19.9k | Infrastructure for computer-use agents, providing sandboxes and SDKs that let agents control full desktops on macOS, Linux, and Windows. |
| Agent Zero | ★ 18.4k | A general-purpose personal agent framework that uses the computer, terminal, and code as its main tools to complete tasks. |
| Browser Use Web UI | ★ 16.2k | A user-friendly web UI, built on Gradio, that lets you control browser-use AI agents, pick from many LLMs, and use your own browser. |