Skip to content

isIOS ​

isIOS is a utility function that detects whether the current device is running iOS or iPadOS.

Notes on platform inconsistencies:

  • Prior to iPadOS 13, iPads reported their platform as "iPad" (or matched /iPad/ in UA).
  • Starting from iPadOS 13, Apple changed the platform string to "MacIntel" to make websites treat iPadOS as desktop-class Safari. However, these devices still expose multi-touch capabilities.

Interface ​

ts
function isIOS(userAgent?: string): boolean;

Parameters ​

  • userAgentstring

    Optional user agent string to check. Defaults to navigator.userAgent.

Return Value ​

  • boolean

    true if the device is running iOS or iPadOS, false otherwise. Returns false on server-side rendering environments.

Example ​

tsx
if (isIOS()) {
  // iOS-specific code
  enableIOSOptimizations();
}
tsx
// With custom user agent
const isIOSDevice = isIOS(
  'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X)'
);

Released under the MIT License.