Using Browserbase
You can use a service that provides a headless browser—such as Browserbase—to run your Bytebot queries. A headless browser helps you avoid running a complete instance Chrome on your production hardware. Browserbase makes it easy to deploy a headless browser.
Sign up for Browserbase and obtain an API key
To start, you will need an API key from Browserbase. You can sign up for access at Browserbase.
Once you have obtained an API key from the Browserbase team, you will need to update your .env file accordingly.
Use the Bytebot client with Browserbase
First, you need to modify your Puppeteer code to use Browserbase. You can access additional guidance via the Browserbase documentation.
First, you’ll need to replace the puppeteer.launch()
call with a call to puppeteer.connect()
with the Browserbase URL and API key.
You may still want to launch the browser locally during development and testing, and only use Browserbase in production. This can be achieved by using another environment variable to determine whether to use Browserbase or not.
Full Browserbase example
The following is a complete example of using Browserbase with Bytebot to execute an action. It assumes that:
- The
@bytebot/sdk
package andpuppeteer
are correctly installed - The Browserbase API key is set as an environment variable
- A Bytebot API key is set as an environment variable
- An environment variable (
IS_PRODUCTION
) is set to determine whether to use Browserbase or not