Skip to content

Commit ade59cb

Browse files
fix ref for deployments guide (#1006)
# why # what changed # test plan Co-authored-by: miguel <miguelg71921@gmail.com>
1 parent 9e8c173 commit ade59cb

File tree

1 file changed

+25
-47
lines changed

1 file changed

+25
-47
lines changed

docs/best-practices/deployments.mdx

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ description: 'Deploy your AI agents and automations to the cloud'
1111

1212
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.
1313

14-
### Short answer
15-
- **Wrap your script as a Vercel Function** (no Next.js needed)
16-
- **Set environment variables**
17-
- **Deploy with Vercel**
18-
1914
### 1. Install Vercel CLI
2015

2116
To download and install Vercel CLI, run one of the following commands:
@@ -77,7 +72,6 @@ export default async function handler(req: VercelRequest, res: VercelResponse):
7772
region: "us-west-2",
7873
browserSettings: {
7974
blockAds: true,
80-
viewport: { width: 1920, height: 1080 },
8175
},
8276
},
8377
});
@@ -105,22 +99,19 @@ export default async function handler(req: VercelRequest, res: VercelResponse):
10599

106100
```json
107101
{
108-
"name": "bb-stagehand-on-vercel",
109-
"private": true,
110-
"type": "module",
111-
"engines": { "node": ">=18" },
112-
"dependencies": {
113-
"@browserbasehq/stagehand": "^2.4.3",
114-
"zod": "^3.23.8"
115-
},
116-
"devDependencies": {
117-
"typescript": "^5.6.0",
118-
"@types/node": "^20.12.12",
119-
"@vercel/node": "^3.2.20"
120-
},
121-
"scripts": {
122-
"build": "tsc -p tsconfig.json"
123-
}
102+
"name": "bb-stagehand-on-vercel",
103+
"private": true,
104+
"type": "module",
105+
"engines": { "node": ">=18" },
106+
"dependencies": {
107+
"@browserbasehq/stagehand": "^2.4.3",
108+
"zod": "^3.25.0"
109+
},
110+
"devDependencies": {
111+
"typescript": "^5.6.0",
112+
"@types/node": "^20.12.12",
113+
"@vercel/node": "^3.2.20"
114+
}
124115
}
125116
```
126117

@@ -149,14 +140,13 @@ export default async function handler(req: VercelRequest, res: VercelResponse):
149140
"$schema": "https://openapi.vercel.sh/vercel.json",
150141
"functions": {
151142
"api/run.ts": {
152-
"runtime": "nodejs22.x",
153143
"maxDuration": 60
154144
}
155145
}
156146
}
157147
```
158148

159-
Increase `maxDuration` as your plan allows. See Vercel's docs for up-to-date limits. Edge runtime may allow longer limits on Pro/Enterprise with Fluid compute.
149+
See Vercel's [configuring functions](https://vercel.com/docs/functions/configuring-functions) docs for more details.
160150

161151
### 7. Link your project
162152

@@ -168,9 +158,6 @@ vercel login
168158

169159
# link the current directory to a Vercel project (interactive)
170160
vercel link
171-
172-
# or non-interactive if you know the project
173-
# vercel link --project <PROJECT_NAME_OR_ID> --yes
174161
```
175162

176163
### 8. Environment variables
@@ -186,7 +173,7 @@ vercel env add GOOGLE_API_KEY
186173

187174
See also: [Browser Environment](/configuration/environment) for details on required variables.
188175

189-
### Test locally (optional)
176+
### 9. Test locally
190177

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

@@ -195,29 +182,17 @@ Replicate the Vercel environment locally to exercise your Function before deploy
195182
npm install
196183

197184
# start the local Vercel dev server
198-
vercel dev
199-
```
200-
201-
Useful options:
202-
203-
```bash
204-
# specify port
205185
vercel dev --listen 5005
206-
207-
# skip interactive setup prompts
208-
vercel dev --yes
209186
```
210187

211-
If your framework's dev server already supports Functions (e.g., `next dev` for Next.js), prefer that. For this non-framework "Other" project, `vercel dev` is recommended.
212-
213-
### 9. Deploy
188+
### 10. Deploy
214189

215190
```bash
216191
vercel
217192
vercel --prod
218193
```
219194

220-
### 10. Call it
195+
### Execute the function
221196

222197
```bash
223198
curl -X POST https://<your-deployment>/api/run
@@ -231,16 +206,19 @@ Hit the same endpoint on a schedule by extending `vercel.json`:
231206
{
232207
"$schema": "https://openapi.vercel.sh/vercel.json",
233208
"functions": {
234-
"api/run.ts": { "runtime": "nodejs22.x", "maxDuration": 60 }
209+
"api/run.ts": {
210+
"maxDuration": 60
211+
}
212+
}
235213
},
236214
"crons": [
237215
{ "path": "/api/run", "schedule": "0 * * * *" }
238216
]
239217
}
240218
```
241219

242-
### Notes that matter
243-
- **No local browsers needed** with `env: "BROWSERBASE"`; Browserbase provides the browsers.
244-
- **Keep the function fast**: Offload browser work to Browserbase and return JSON promptly.
220+
### Features
221+
- **No local browsers needed** with `env: "BROWSERBASE"`. [Browserbase](https://www.browserbase.com/) provides the browsers.
222+
- **Fast functionality**: Offload browser work to Browserbase and return JSON promptly.
245223
- **Long-running tasks**: Raise `maxDuration` and/or consider Edge runtime limits depending on plan.
246-
- **Vercel recognizes** `/api/*.ts` functions for non-framework projects—see Vercel Functions docs for behavior and limits.
224+

0 commit comments

Comments
 (0)