Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Puppeteer Puppeteer DetectBrowserPlatform

From Leeroopedia
Knowledge Sources
Domains Browser_Management, System_Detection
Last Updated 2026-02-11 23:00 GMT

Overview

Concrete tool for detecting the current OS platform and architecture for browser binary selection, provided by the @puppeteer/browsers package.

Description

The detectBrowserPlatform() function uses Node.js os.platform() and os.arch() to determine the appropriate BrowserPlatform enum value. Returns undefined if the platform is not supported.

Usage

Call this function to determine which browser binary variant to download for the current system.

Code Reference

Source Location

  • Repository: puppeteer
  • File: packages/browsers/src/detectPlatform.ts
  • Lines: 14-33

Signature

function detectBrowserPlatform(): BrowserPlatform | undefined;

Import

import {detectBrowserPlatform} from '@puppeteer/browsers';

I/O Contract

Inputs

Name Type Required Description
(none) Auto-detects from runtime environment

Outputs

Name Type Description
return BrowserPlatform or undefined Platform enum: 'linux', 'linux_arm', 'mac', 'mac_arm', 'win32', 'win64', or undefined if unsupported

Usage Examples

import {detectBrowserPlatform} from '@puppeteer/browsers';

const platform = detectBrowserPlatform();
if (!platform) {
  throw new Error('Unsupported platform');
}
console.log(`Detected platform: ${platform}`);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment