Skip to main content

isMobile()

true when the current environment looks like a mobile or tablet device, based on a UA regex.

Signature(options?: DetectOptions) => boolean
MatchesiPhone, iPod, iPad, Android+Mobile, BlackBerry, webOS, Opera Mini, etc.
Tree-shakes to~600 bytes (regex weight)

What it matches

A compiled regex of common mobile / tablet tokens — derived from detectmobilebrowsers.com and lightly modernized:

  • iPhone, iPod, iPad
  • Android + Mobile
  • BlackBerry, webOS, Symbian, Maemo, Windows CE
  • Mobile-specific Firefox builds (Mobile.+Firefox)
  • Opera Mobi, Opera Mini
  • Many others — see src/is-mobile.ts.
This is a heuristic, not a feature check

For breakpoint decisions, prefer:

window.matchMedia('(pointer: coarse)').matches; // touch-first device
window.matchMedia('(max-width: 768px)').matches; // narrow viewport
@media (max-width: 768px) { /* … */ }
@media (pointer: coarse) { /* … */ }

isMobile() is appropriate for analytics, server hints, and download-badge logic.

Examples

import { isMobile } from 'get-browser';

if (isMobile()) {
document.body.classList.add('is-mobile');
}

iPadOS limitation

iPadOS 13+ defaults to a Mac UA — we can only identify iPads that explicitly self-identify (Safari's Request Mobile Website mode, embedded WebViews, etc.). See the isSafari() notes for the full story.

See also