@rtorcato/browser-common / common
common
Type Aliases
Platform
Platform =
"ios"|"android"|"macos"|"windows"|"linux"|"unknown"
Defined in: common/index.ts:33
Variables
isBrowser
constisBrowser:boolean
Defined in: common/index.ts:5
Checks if the code is running in a browser environment.
Returns
True if running in a browser, false otherwise.
Functions
getUserAgent()
getUserAgent():
string|undefined
Defined in: common/index.ts:11
Returns the browser's user agent string, if available.
Returns
string | undefined
The user agent string or undefined if not in a browser.
isMobile()
isMobile():
boolean
Defined in: common/index.ts:19
Detects if the user is on a mobile device.
Returns
boolean
True if the user agent is a mobile device, false otherwise.
getBrowserLanguage()
getBrowserLanguage():
string|undefined
Defined in: common/index.ts:29
Returns the browser's preferred language, if available.
Returns
string | undefined
The preferred language or undefined if not in a browser.
getPlatform()
getPlatform():
Platform
Defined in: common/index.ts:42
Detects the operating system platform. Prefers navigator.userAgentData.platform, then
falls back to the user agent, checking iOS and Android before macOS and Linux (an iPhone UA
says "like Mac OS X", an Android UA says "Linux"). iPadOS 13+ sends a Mac UA, so a Mac UA
with touch points is reported as iOS.
Returns
The platform, or 'unknown' outside a browser.
isIOS()
isIOS():
boolean
Defined in: common/index.ts:59
Returns
boolean
True on iOS or iPadOS.
isAndroid()
isAndroid():
boolean
Defined in: common/index.ts:62
Returns
boolean
True on Android.