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
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- ssrTSSROptions
- 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
Return value
The value returned by this util.
- An IDisplayPlatform object containing boolean flags: android, ios, cordova, electron, chrome, edge, firefox, opera, win, mac, ssr, and touch.
Usage
Examples
Ready-to-paste usage snippets.
Detect platform and apply conditional behaviour