BrowserStack Node.js Client
This client provides a JavaScript interface for integrating Node.js applications with the BrowserStack platform. It offers programmatic access to various BrowserStack APIs, including the general REST API, the Automate API for WebDriver-based testing, the App Automate API for mobile application testing, and the Screenshots API for generating cross-browser screenshots. Developers can use it to manage virtual browsers, define testing workers, administer projects and builds, and query session information directly from their Node.js environment. As of April 2026, the package's current stable version is 1.6.1, last updated in February 2019. This indicates the project is effectively abandoned, lacking any ongoing maintenance, feature development, or security updates. Its primary differentiator was providing a unified Node.js client across multiple BrowserStack services at the time of its last release. However, due to its outdated nature, users are strongly advised to seek more recent and officially maintained BrowserStack SDKs or alternatives for robust and secure integrations. It exclusively supports CommonJS module loading.
Common errors
-
Error: Cannot find module 'browserstack'
cause The 'browserstack' package has not been installed or is not accessible in the current project.fixRun `npm install browserstack` to add the package to your project's dependencies. -
Error: Authentication failed, please check your credentials.
cause The provided username or access key (password) for BrowserStack is incorrect or expired.fixVerify your BrowserStack username and access key in your account settings. Ensure they are correctly passed to `BrowserStack.createClient()` and its variants. -
TypeError: BrowserStack.createClient is not a function
cause The `BrowserStack` object was either not correctly imported/required, or the property `createClient` does not exist on it.fixEnsure you are using `const BrowserStack = require('browserstack');` for import. Also, double-check that you are calling the method correctly, as case sensitivity matters. -
TypeError: Cannot read properties of undefined (reading 'getBrowsers')
cause This typically occurs if the client object (e.g., `client`, `automateClient`) was not successfully instantiated, often due to an error in `createClient` or its variants.fixAdd error handling to the client creation calls (e.g., `BrowserStack.createClient(credentials, function(error, client) { ... });`) or ensure `browserStackCredentials` are valid.
Warnings
- breaking This package is effectively abandoned, with its last update in February 2019. It is no longer maintained, meaning there will be no new features, bug fixes, or compatibility updates for newer Node.js versions or BrowserStack API changes. Consider using an officially supported or more recently maintained SDK.
- gotcha The package is CommonJS-only (uses `require()`) and does not natively support ES Modules (`import`). Attempting to use `import` statements will result in a runtime error like 'ERR_REQUIRE_ESM'.
- gotcha Due to its age, this client may rely on older versions of Node.js or internal dependencies. It might not function correctly or might require polyfills in modern Node.js environments (v16+).
- breaking BrowserStack's public APIs may have evolved significantly since this client's last update in 2019. Some functionalities might be deprecated, changed, or require different parameters than what this client exposes, potentially leading to incorrect responses or errors.
Install
-
npm install browserstack -
yarn add browserstack -
pnpm add browserstack
Imports
- BrowserStack
import BrowserStack from 'browserstack';
const BrowserStack = require('browserstack'); - createClient
import { createClient } from 'browserstack';const BrowserStack = require('browserstack'); const client = BrowserStack.createClient(credentials); - createAutomateClient
import { createAutomateClient } from 'browserstack';const BrowserStack = require('browserstack'); const automateClient = BrowserStack.createAutomateClient(credentials);
Quickstart
const BrowserStack = require('browserstack');
// IMPORTANT: Replace with your actual BrowserStack credentials or environment variables
const browserStackCredentials = {
username: process.env.BROWSERSTACK_USERNAME ?? 'YOUR_USERNAME',
password: process.env.BROWSERSTACK_ACCESS_KEY ?? 'YOUR_ACCESS_KEY'
};
if (browserStackCredentials.username === 'YOUR_USERNAME' || browserStackCredentials.password === 'YOUR_ACCESS_KEY') {
console.warn('WARNING: Please set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables, or replace placeholders.');
}
// REST API Client
const client = BrowserStack.createClient(browserStackCredentials);
client.getBrowsers(function(error, browsers) {
if (error) {
console.error('Error fetching browsers from REST API:', error);
return;
}
console.log('Available browsers for REST API testing (first 5):');
console.log(browsers.slice(0, 5));
});
// Automate API Client
const automateClient = BrowserStack.createAutomateClient(browserStackCredentials);
automateClient.getBrowsers(function(error, browsers) {
if (error) {
console.error('Error fetching browsers from Automate API:', error);
return;
}
console.log('Available browsers for Automate API testing (first 5):');
console.log(browsers.slice(0, 5));
});