- Stagehand + Vercel AI SDK
1
Get your API keys
You’ll need credentials from two services:Browserbase: Go to the Dashboard Settings and copy your API key.
Anthropic: Get your API key from the Anthropic Console.Create a

.env.local file with:2
Install dependencies
3
Create a Stagehand session
Initialize a Stagehand instance connected to Browserbase. Each session gets its own cloud browser with a live debug view.
4
Define research functions
Each research function takes a Stagehand instance, navigates to a source, and uses You can create similar functions for Wikipedia, YouTube, Hacker News, and Google News, each using
stagehand.extract() to pull structured data from the page using AI.Here’s an example that searches DuckDuckGo and visits top results:stagehand.extract() with different schemas. See the full template for all five research functions.5
Create the API route with SSE streaming
Create
app/api/research/route.ts to handle research requests. This route creates parallel Stagehand sessions and streams findings back via Server-Sent Events.6
Handle concurrency limits
Free Browserbase plans have a concurrency limit of 1. The template automatically detects this and falls back to running sessions sequentially:
Full Template on GitHub
Browse the complete source code with frontend components, SSE streaming, and live browser views.
Deploy to Vercel
One-click deploy with automatic Browserbase setup via the Vercel Marketplace.