Stagehand

Active
GitHub TypeScript MIT

Description

The SDK for browser agents by Browserbase. Provides act, extract, and observe primitives for AI agents to naturally browse and interact with web pages.

Key Features

  • Three-primitive API — act (execute actions), extract (get data), observe (inspect page)
  • Hybrid natural language + code — freely switch between AI-driven and deterministic code control
  • Auto-caching and self-healing — cache repeat actions to skip LLM inference, auto-fix on page changes
  • TypeScript and Python dual SDK — TS and Python implementations for different tech stacks
  • Zod structured data extraction — define targets with Zod schemas, get type-safe structured results
  • Agent mode — built-in agent() method for autonomous multi-step complex task execution

Use Cases

💡 Building browser agents that autonomously browse and interact with web pages
💡 Automating testing of web apps requiring login or complex interactions
💡 Batch-extracting structured product or pricing data from any website
💡 Real-time web data collection layer for RAG systems
💡 Creating reusable web automation workflow scripts

Quick Start

npm install @browserbasehq/stagehand

import { Stagehand } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
  env: "LOCAL",
});
await stagehand.init();

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

await stagehand.act("click on the stagehand repo");

const { author, title } = await stagehand.extract(
  "extract the author and title of the latest PR",
  {
    author: z.string(),
    title: z.string(),
  }
);

console.log(author, title);
await stagehand.close();

Related Projects