Load a custom Chrome Extension
Upload an extension
A custom Chrome Extension is necessary for some use cases to enable advanced browser features. Extension support with headless Chrome has always been limited, but with Browserbase, it’s easy.
First, refer to the Upload an Extension API and execute the curl
command. You should receive a response containing the extension’s id
. Make sure to save the id
of the extension, as you’ll need it to create a session.
The file path should point to the zipped extension file. Do not unpack the zip file; it should be a binary file. Example path:
build/chrome-mv3-prod.zip
You must upload a valid Chrome Extension in a
.zip
file format containing amanifest.json
at the root. This file must be smaller than 4.5 MB.Starting a session with a Chrome Extension will increase session creation time slightly, as we have to load the extension and restart the browser.
Feel free to use your own Chrome Extension, or clone the example Browserbase extension.
Clone the example Browserbase extension
Clone this extension repo to try it out!
Creating a session with the extension
Once you’re finished and ready to use your Chrome Extension in browser sessions, let’s create a session and load the extension into the browser.
We’ll create a new session using the Session API create session endpoint. Make sure to include the extensionId
parameter, which is the id
of the extension you’ve previously uploaded.
You should receive a response containing the session’s id
.
Make sure to save the session id
. You’ll need it to connect to the session and verify that the extension is loaded correctly.
Verify the extension is loaded
We need to verify that the extension is loaded correctly. This is done by checking for a specific element or behavior that your extension introduces. Below is an example of how you might do this:
You should see that if you used any content scripts in your extension, they will be loaded into the browser.
Was this page helpful?