Skip to main content
🌟 Preview: Browser Functions - Deploy your web automation code directly on Browserbase with browser functions. Scale your act() automations in the cloud with zero infrastructure setup. Reach out to hello@browserbase.com to get beta access.

Deploy on Vercel

Securely run Stagehand on Browserbase inside a Vercel Function. This guide shows a minimal, production-safe HTTP endpoint you can call directly or on a schedule.

1. Install Vercel CLI

To download and install Vercel CLI, run one of the following commands:

2. Project layout

Create the structure with:

3. api/run.ts (Node.js runtime)

4. package.json

5. tsconfig.json

6. vercel.json

See Vercel’s configuring functions docs for more details. Link your local folder to a Vercel project before configuring environment variables:

8. Environment variables

Do not commit .env in production. Add variables via Vercel CLI:
See also: Browser Environment for details on required variables.

9. Test locally

Replicate the Vercel environment locally to exercise your Function before deploying. Run from the project root.

10. Deploy

Execute the function

Configure Protection Bypass for Automation

Before invoking the production URL, create a Protection Bypass for Automation:
  1. Generate a 32-character secret (you can use openssl rand -hex 16)
  2. Go to your project in Vercel
  3. Navigate to Settings → Deployment Protection
  4. Add the secret to “Protection Bypass for Automation”
Then invoke the function with the bypass header:

Optional: Cron on Vercel

Hit the same endpoint on a schedule by extending vercel.json:

Features

  • No local browsers needed with env: "BROWSERBASE". Browserbase provides the browsers.
  • Fast functionality: Offload browser work to Browserbase and return JSON promptly.
  • Long-running tasks: Raise maxDuration and/or consider Edge runtime limits depending on plan.