Skip to content

isMobile ​

The isMobile function checks if the code is running on a mobile device.

Syntax ​

typescript
isMobile(): boolean;

Parameters ​

This function does not take any parameters.

Returns ​

TypeDescription
booleantrue if running on a mobile device, false otherwise

Examples ​

typescript
isMobile();
// => true (on mobile devices)
// => false (on desktop)

Notes ​

  • Uses the navigator.userAgent property to identify mobile devices.
  • Useful for conditioning mobile-specific executions.

References ​

Released under the MIT License.