Skip to main content

Stagehand

AI-powered web automation and structured data extraction SDK

Built on Playwright by Browserbase, Stagehand provides high-level `act()`, `extract()`, and `observe()` primitives for resilient web automation.

Quickstart Execution

stagehand-demo.ts

Get started with Stagehand in your project.

import { Stagehand } from '@browserbasehq/stagehand'
import { z } from 'zod'

const stagehand = new Stagehand({ env: 'LOCAL' })
await stagehand.init()

await stagehand.page.goto('https://www.dsb.dk')
await stagehand.page.act('Click on Rejser and enter København H to Aarhus H')

const departures = await stagehand.page.extract({
  instruction: 'Extract the earliest three train departure times and prices',
  schema: z.object({ departures: z.array(z.string()) })
})

console.log(departures)
await stagehand.close()

About Stagehand

Stagehand is an open-source AI web automation framework built specifically for developers who need robust browser automations that do not break when CSS classes or DOM hierarchies change. Instead of brittle selectors, Stagehand uses natural language intent for actions and Zod schemas for structured extraction.

DK

Danish Product & Data Recipes

How developers and agents use Stagehand to connect with Danish digital infrastructure.

Extract Real-time Danish Grocery Prices (Nemlig / Bilka)

Use `stagehand.extract()` with a Zod schema to extract organic milk prices, discounts, and delivery slots without brittle CSS selectors.

const prices = await stagehand.page.extract({ instruction: "Extract all organic milk items with their price in DKK and discount status", schema: z.object({ items: z.array(z.object({ name: z.string(), priceDkk: z.number(), onSale: z.boolean() })) }) })

Key Capabilities

page.act() for natural language UI interactions
page.extract() with strict Zod type validation
page.observe() to suggest possible agent actions on current DOM
Built-in Playwright reliability and caching
Runs locally or connected to cloud browser fleets (Browserbase, Browserless)