Skip to content

BrowserStack Client

npmBuild Status

TypeScript SDK for all BrowserStack REST APIs. One package, every product, full type safety.

Installation

bash
npm install @dot-slash/browserstack-client

Requirements

  • Node.js 22 or higher
  • A BrowserStack account with the relevant product subscriptions

Authentication

Set credentials in your environment — no constructor arguments needed:

bash
export BROWSERSTACK_USERNAME=<your-username>
export BROWSERSTACK_ACCESS_KEY=<your-access-key>

Or pass them explicitly to any client constructor.

Usage

ts
import {
  AutomateClient,
  AppAutomateClient,
  LocalTestingBinary,
  AccessibilityClient,
  TestManagementClient,
  TestReportingClient,
  ScreenshotsClient,
} from "@dot-slash/browserstack-client";

Tree-shaking: If bundle size matters (e.g. Lambda, browser), import from the product subpath instead — @dot-slash/browserstack-client/automate, /app-automate, /local-testing, /accessibility, /test-management, /test-reporting, /screenshots. Bundlers will then include only that product's code.

Automate — browser automation

ts
import { AutomateClient } from "@dot-slash/browserstack-client";

const client  = new AutomateClient();
const plan    = await client.getPlan();
const builds  = await client.getBuilds();

App Automate — mobile app automation

ts
import { AppAutomateClient } from "@dot-slash/browserstack-client";

const client   = new AppAutomateClient();
const projects = await client.getProjects();
const builds   = await client.getBuilds(projects[0].id);

Local Testing — tunnel management

ts
import { LocalTestingBinary } from "@dot-slash/browserstack-client";

const tunnel = new LocalTestingBinary({ accessKey: process.env.BROWSERSTACK_ACCESS_KEY });

await tunnel.start();
// ... run tests against localhost ...
await tunnel.stop();

Accessibility

ts
import { AccessibilityClient } from "@dot-slash/browserstack-client";

const client  = new AccessibilityClient();
const reports = await client.getWorkflowAnalyzerReports();

Test Management

ts
import { TestManagementClient } from "@dot-slash/browserstack-client";

const client   = new TestManagementClient();
const projects = await client.getProjects();

Test Reporting & Analytics

ts
import { TestReportingClient } from "@dot-slash/browserstack-client";

const client = new TestReportingClient();

const build = await client.startBuild({
  projectName: "my-project",
  buildName:   "my-build",
  framework:   "playwright",
});

// ... run tests ...

await client.finishBuild(build.buildHashedId, { status: "passed" });

Screenshots — cross-browser screenshots

ts
import { ScreenshotsClient } from "@dot-slash/browserstack-client";

const client = new ScreenshotsClient();

await client.launch(
  {
    url: "https://example.com",
    browsers: [{ browser: "chrome", browser_version: "latest", os: "Windows", os_version: "11" }],
  },
  (screenshot) => console.log("captured:", screenshot.imageUrl)
);

CLI

A unified CLI is also available for local testing and product interactions:

bash
npx @dot-slash/browserstack-cli local start
npx @dot-slash/browserstack-cli local run-with -- npm test
npx @dot-slash/browserstack-cli local stop

Individual packages

Only need one product? Install its focused package directly:

PackageProduct
@dot-slash/browserstack-automateBrowser automation
@dot-slash/browserstack-app-automateMobile app automation
@dot-slash/browserstack-local-testingLocal tunnel binary
@dot-slash/browserstack-accessibilityAccessibility testing
@dot-slash/browserstack-test-managementTest case management
@dot-slash/browserstack-test-reportingTest analytics
@dot-slash/browserstack-screenshotsScreenshot automation

Documentation

shirish87.github.io/browserstack-client

Thanks

Sponsored access to BrowserStack, courtesy BrowserStack.