Quickstart
Use create-browser-app to get started in 1 minute
Check out the Browserbase Playbook
We’ve created a Github repository with plenty of ready-to-run guides for Stagehand, including persistent contexts and deploying to Vercel.
Prerequisites
Before you begin, you’ll need to install Node.js and NPM. We highly recommend using nvm to manage your Node.js versions, and running on Node version 20+.
We highly recommend using the Node.js runtime environment to run Stagehand scripts, as opposed to newer alternatives like Deno or Bun.
Create a new project
You can use npx to create a new project. You should have npx included with npm
, the default package manager for Node.js.
To create a blank Stagehand project without the quickstart example, run:
This will create a new directory called my-app
, and install the Stagehand package. It will ask you the following questions:
Large Language Models
In addition, you’ll need either an OpenAI API Key or Anthropic API key. Stagehand allows you to choose between the following models:
- OpenAI GPT-4o (Get API Key)
- Anthropic Claude 3.5 Sonnet (Get API Key)
We also support GPT-4o-mini, but it is not recommended for production use.
Browserbase
Lastly, if you want access to advanced features like custom contexts, extensions, and captcha solving, you’ll need a Browserbase account. We give you 10 free sessions to get started. You can get your Project ID and API Key from the Browserbase dashboard.
Install dependencies and run the script
Use the package manager of your choice to install the dependencies. We also have a postinstall
script that will automatically install the Playwright browser with playwright install
.
View the code on Github
All of the code for this quickstart is available on Github.