SkillsApr 7, 2026·2 min read

Stagehand — AI-Powered Browser Automation SDK

TypeScript SDK that lets you automate browsers using natural language and visual understanding. AI sees the page like a human does. Built on Playwright. 10,000+ GitHub stars.

SK
Skill Factory · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

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

const stagehand = new Stagehand({ env: "LOCAL" });
await stagehand.init();
await stagehand.page.goto("https://news.ycombinator.com");

// AI understands the page visually
await stagehand.act({ action: "click on the first article title" });
const title = await stagehand.extract({
  instruction: "extract the title and score of the top story",
  schema: z.object({ title: z.string(), score: z.number() }),
});

Intro

Stagehand is a TypeScript SDK for AI-powered browser automation with 10,000+ GitHub stars. Unlike Playwright where you write CSS selectors and XPath, Stagehand lets you describe actions in natural language — the AI sees the page visually and figures out what to click, fill, or extract. Built on Playwright, it combines the reliability of traditional automation with the flexibility of AI vision. Best for developers who need browser automation that does not break when UI changes. Works with: any website, Playwright-compatible. Setup time: under 3 minutes.


Three Core Methods

act() — Do Something

await stagehand.act({ action: "click the Sign In button" });
await stagehand.act({ action: "fill in the email field with test@example.com" });
await stagehand.act({ action: "select Monthly from the billing dropdown" });
await stagehand.act({ action: "scroll down to the pricing section" });

extract() — Get Data

const data = await stagehand.extract({
  instruction: "extract all product names and prices",
  schema: z.object({
    products: z.array(z.object({
      name: z.string(),
      price: z.number(),
    })),
  }),
});

observe() — Understand the Page

const elements = await stagehand.observe({
  instruction: "find all interactive elements on this page",
});
// Returns: buttons, links, inputs with their descriptions

Why Stagehand Over Playwright

Playwright Stagehand
page.click('[data-testid="login"]') act("click the Login button")
Breaks when selectors change Works even after UI redesign
Need to inspect DOM manually AI sees the page visually
Complex selector chains Natural language instructions

Best of Both Worlds

Stagehand is built on Playwright — you can mix both:

// Use Stagehand for AI-powered steps
await stagehand.act({ action: "navigate to the settings page" });

// Drop down to Playwright for precise control
await stagehand.page.waitForSelector("#settings-form");
const value = await stagehand.page.inputValue("#email");

Structured Extraction with Zod

import { z } from "zod";

const articles = await stagehand.extract({
  instruction: "extract all news articles from this page",
  schema: z.object({
    articles: z.array(z.object({
      title: z.string(),
      author: z.string(),
      date: z.string(),
      summary: z.string(),
    })),
  }),
});
// Fully typed: articles.articles[0].title

Use Cases

Scenario Example
E2E testing "Login, add item to cart, checkout"
Web scraping "Extract all job listings from this page"
Form filling "Fill out the application form with this data"
Monitoring "Check if the status page shows all green"
Screenshots "Navigate to dashboard and take a screenshot"

Key Stats

  • 10,000+ GitHub stars
  • Built on Playwright
  • 3 methods: act, extract, observe
  • Zod schema for typed extraction
  • Visual AI understanding

FAQ

Q: What is Stagehand? A: A TypeScript SDK for browser automation using natural language — AI sees the page visually and performs actions without CSS selectors.

Q: Is Stagehand free? A: Yes, open-source under MIT. Uses your own LLM API key for vision.

Q: Does Stagehand replace Playwright? A: No, it is built on Playwright and adds AI-powered natural language control. You can use both together.


🙏

Source & Thanks

Created by Browserbase. Licensed under MIT.

stagehand — stars 10,000+

Thanks for making browser automation speak human.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets