Skip to main content

isSafari()

true when the current environment is Apple Safari on macOS or iOS — but not other browsers using iOS WebKit (Chrome iOS, Firefox iOS, Edge iOS, Opera iOS).

Signature(options?: DetectOptions) => boolean
Tree-shakes to~400 bytes
ExcludesChrome iOS, Firefox iOS, Edge iOS, Opera iOS

Heuristic

  1. navigator.vendor must start with "Apple".
  2. The UA must contain Safari but not any of CriOS, FxiOS, EdgiOS, OPiOS, Chrome, Chromium, or OPR.

When you pass { userAgent } without vendor (e.g. SSR with just the request header), the function falls back to UA-only matching — same rules, no vendor check.

Examples

import { isSafari, isMobile } from 'get-browser';

if (isSafari() && isMobile()) {
applyMobileSafariFix();
}

iPadOS gotcha

iPad ≡ Mac (sometimes)

Since iPadOS 13 (2019), iPad's default Safari UA looks exactly like macOS Safari — Apple ships a Mac UA so iPads request desktop sites. There is no reliable way to distinguish them from a Mac. isSafari() returns true in both cases, and isMobile() cannot identify the iPad.

When the user toggles Request Mobile Website, the UA reverts to including iPad — in that case isMobile() also returns true.

const desktopMacOrIpad =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.4 Safari/605.1.15';
const requestMobileIpad =
'Mozilla/5.0 (iPad; CPU OS 18_4 like Mac OS X) AppleWebKit/605.1.15 Version/18.4 Mobile/15E148 Safari/604.1';

isSafari({ userAgent: desktopMacOrIpad, vendor: 'Apple Computer, Inc.' }); // true
isSafari({ userAgent: requestMobileIpad, vendor: 'Apple Computer, Inc.' }); // true

See also