Learn how to setup your project, deploy to Vercel, and scale with Browserbase
vercel-automation
NextRequest
and NextResponse
to simplify working with native Request/Response APIs.app
directory.html
directory in our app/api
folder. To create an endpoint, we’ll add a route.ts
file that will handle the API requests. We’ll use the GET
method to retrieve HTML content from a specified URL.
Here’s the code for our first route handler:
screenshot/route.ts
and utilize the following code to enable screenshot abilities.
Act
, Extract
, and Observe
.
In this example, we’ve initialized Stagehand with our Browserbase credentials and an LLM model to efficiently fill out a sample form, rather needing to write a more complex Puppeteer script.
Below is the same web automation task, comparing the Puppeteer implementation and Stagehand implementation.
.env
file.http://localhost:3000/api
http://localhost:3000/api/html
http://localhost:3000/api/screenshot
http://localhost:3000/api/form
200
status code when working correctly.