# 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.

## Overview

- **Website**: https://stagehand.dev
- **Docs**: https://docs.stagehand.dev
- **GitHub**: https://github.com/browserbase/stagehand
- **License / Pricing**: Open Source
- **Directory Entry**: https://agentaccess.dk/enablers/stagehand

## About

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.

## Key Features

- 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)

## Danish System Application Recipes

### 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.

```bash
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() }))
  })
})
```

## Quickstart

```typescript
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()
```

---
Source: [AgentAccess Enablers](https://agentaccess.dk/enablers/stagehand)