browserbase/stagehand

The SDK to extract data and interact with any site on the web. Get started with Claude Code, Codex, Eve, Mastra, and more.

What it solves

Stagehand removes the usual pain of browser automation: scripts that break when a website changes its layout, and AI agents that waste tokens and time trying to parse an entire page. It gives developers and agents a way to tell a browser in plain English what to do—find a field, click a button, pull out data—and get reliable, structured results without hardcoding every selector or re-writing logic when a site is redesigned.

How it works

Stagehand is an SDK that runs alongside a browser (local Chrome or the hosted Browserbase cloud). You give it natural-language instructions and it turns those into real browser actions. Three core functions do the heavy lifting:

  • observe finds the actual CSS selector for an element you describe—like "the email input"—so you can fill it in yourself, and the AI model never touches your credentials.
  • act performs an action you describe, like "click the sign in button". It re-evaluates the page if the site has changed, so it self-heals and the action still works.
  • extract reads data from the page and returns it in a schema you define (e.g., a list of invoices with number, amount, and paid status), validated by tools like Zod (TypeScript), Pydantic (Python), or Go structs.

The SDK is built on Playwright-style APIs (goto, locator, screenshot), so it feels familiar if you already know those. It trims page context to only what the agent needs, which cuts token usage. It also runs as a browser extension to reduce latency on every action, and it supports modern web complexities like nested iframes and closed Shadow DOMs.

You can run it locally with Google Chrome installed, or point it at Browserbase's cloud. In the cloud, the Model Gateway automatically picks the cheapest suitable model for each step, and server-side caching means repeated identical calls don't spend any tokens. Stagehand also offers lightweight search and fetch functions that work without spinning up a browser at all.

Who it's for

  • Developers building web automation scripts or AI agents that need to interact with websites.
  • Teams that have existing Playwright code and want to add AI-driven natural-language actions.
  • Anyone who wants to give a coding agent (like Claude Code or Cursor) the ability to browse the web, via the hosted MCP server.
  • Users of TypeScript, Python, or Go—Stagehand provides a full SDK in all three languages.

Highlights

  • Natural-language browser control: observe, act, extract—no brittle selectors.
  • Self-healing actions that adapt to website redesigns.
  • Token-efficient: only relevant page context is sent to the model.
  • Playwright-compatible API surface across TypeScript, Python, and Go.
  • Built-in support for WebMCP tools, clipboard, batch commands, and OTel traces.
  • Optional Browserbase cloud integration with Model Gateway (auto model selection) and caching.
  • Add-ons: search and fetch for quick web lookups without a browser.
  • Hosted MCP server so any MCP-capable coding agent can navigate and act on the web.

Related

  • Project
  • Project
  • Project
  • Project
  • Project