Extensions

Using Extensions with Hyperbrowser

Hyperbrowser allows you to enhance your browser sessions with custom Chrome extensions.

Uploading an Extension

To use a custom extension with Hyperbrowser:

  1. Create your extension as a directory containing at least a manifest.json file

  2. Compress the directory into a ZIP archive, make sure to zip all the files and not the directory itself

  3. Upload the ZIP file using the Extensions API:

import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
config();

const hbClient = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY });

const uploadExtension = async () => {
  const resp = await hbClient.extensions.create({
    name: "new-extension",
    filePath: "custom-extension.zip",
  });
  console.log(resp);
};

uploadExtension();

The API will return an id that you'll use to attach the extension to a session.

Using an Extension

To use your uploaded extension in a Hyperbrowser session, simply add it in the extensionIds field of the Create Session params:

import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
config();

const hbClient = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY });


const useExtensionInSession = async () => {
  const resp = await hbClient.sessions.create({
    extensionIds: ["<EXTENSION_ID>"],
  });
  console.log(resp);
};

useExtensionInSession();

Once added to a session, these extension behave exactly as they would in a real browser.

Refer to the Extensions API Reference for more details on uploading and managing extensions.

Last updated