Skip to main content

Check out the convex-stagehand repo

Clone the GitHub repo to get started with Stagehand in Convex.

Installation

Install the convex-stagehand component and Zod for schema validation:

Configuration

Add the Stagehand component to your convex/convex.config.ts:
convex/convex.config.ts

Environment Variables

Set the following environment variables in your Convex Dashboard:

Basic Usage

Initialize the Client

Create a Stagehand instance in your Convex action:
convex/actions.ts

Extract Data

Extract structured data from a web page using natural language instructions and Zod schemas:

Perform Actions

Execute browser interactions using plain English:

Observe Elements

Identify interactive elements on a page:

Run Autonomous Tasks

Use the agent API for complex multi-step workflows:

Session Management

For workflows that span multiple operations, you can reuse browser sessions:
Session persistence allows you to preserve authentication state and cookies between operations.

Model Configuration

The default model is openai/gpt-4o. You can configure alternative providers:

Requirements

  • Convex 1.29.3 or later
  • A Browserbase account with API credentials
  • An API key from a supported LLM provider (OpenAI, Anthropic, etc.)

References

Source Code

Browse the complete repository on GitHub

Convex Docs

Learn more about Convex