getPlatform

Commons
stable

Detects the current runtime environment by reading the browser user-agent and returns a typed IDisplayPlatform object with boolean flags for each platform/browser.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

ssr
TSSROptions
SSR configuration object. When provided (and truthy), the user-agent is forced to "ssr" so all flags are false. Use this in SSR environments to avoid window access.

API

Valeur de retour

La valeur retournée par cet util.

An IDisplayPlatform object containing boolean flags: android, ios, cordova, electron, chrome, edge, firefox, opera, win, mac, ssr, and touch.

Usage

Exemples

Extraits de code prêts à coller.

Detect platform and apply conditional behaviour

typescript