Install Stagehand
Add Stagehand to a new or existing project.
For TypeScript/Node.js: We highly recommend using the Node.js runtime environment to run Stagehand scripts, as opposed to newer alternatives like Deno or Bun.
Bun does not support Stagehand since it doesn’t support Playwright.
For Python: We require Python 3.9+ and recommend using uv to manage your virtual environment.
We strongly recommend using Stagehand in a new project with npx create-browser-app
. Check out our quickstart guide to get started.
However, if you have an existing project, you can install Stagehand by installing the @browserbasehq/stagehand
package.
You may also need to install the Playwright browser to run your Stagehand scripts, especially if you’re running locally.
Then, you can use Stagehand in your project by importing the Stagehand
class.
We strongly recommend using Stagehand in a new project with npx create-browser-app
. Check out our quickstart guide to get started.
However, if you have an existing project, you can install Stagehand by installing the @browserbasehq/stagehand
package.
You may also need to install the Playwright browser to run your Stagehand scripts, especially if you’re running locally.
Then, you can use Stagehand in your project by importing the Stagehand
class.
Before you begin, you’ll need Python 3.9+ installed. We recommend using uv to manage your virtual environment.
Recommended: Set up a virtual environment
Install Stagehand Python
If you’re using a virtual environment with uv, you can install Stagehand with:
Set up environment variables
Create a .env
file or export environment variables:
Create your first script
Create a file main.py
:
Run the script