Implementation:Puppeteer Puppeteer DetectBrowserPlatform
Appearance
| 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