Skip to main content
There’s a new way to automate the web: by prompting. But a single prompt fails on complicated scripts. Stagehand lets you prompt at multiple levels of granularity—from agents to single actions—and interweave Playwright or traditional frameworks when you need them. Use any major model provider. 22k GitHub stars, 700k+ weekly downloads. Get started in 5 minutes.
This quickstart uses Model Gateway — LLM requests for Stagehand are routed through your Browserbase API key, so you don’t need a separate model provider account. You can also bring your own API key if you prefer.

Discord

Community support

Docs

Full documentation

Templates

Ready-to-use examples

Quickstart

1

Get your API key

Your API key and Project ID are displayed in the Dashboard Navigation row:
2

Set environment variables

export BROWSERBASE_API_KEY="your-api-key"
3

Install and run

pnpm add @browserbasehq/stagehand
npm pkg set type=module
import { Stagehand } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
  env: "BROWSERBASE",
  model: "google/gemini-3-flash-preview",
});
await stagehand.init();

const page = stagehand.context.pages()[0];
await page.goto("https://news.ycombinator.com");

// Let AI click
await stagehand.act("click on the comments link for the top story");

// Extract structured data
const data = await stagehand.extract("extract the title and points of the top story");
console.log(data);

await stagehand.close();
Save as script.ts, then run:
pnpm dlx tsx script.ts
4

Debug in Session Inspector

See every AI decision in the Stagehand tab of your session at https://browserbase.com/sessions/{session_id}.

Next steps

Stagehand docs

Learn about Stagehand primitives, models, and Browserbase configurations

npx create-browser-app

Scaffold a Stagehand project in one command. TypeScript, zero-config.