# Detect macOS browser

Guess whether the device is a Mac, iPhone or iPad from the platform string.

Canonical: https://1loc.dev/dom/detect-macos-browser/
Version: 1.0.0
Runtime: JavaScript · modern browsers (DOM)
Verification: Usage lines executed in headless Chromium against the fixture markup; no external services
Updated: 2026-10-28

## Implementation

```javascript
function isApplePlatform() { return /Mac|iPhone|iPad|iPod/.test(navigator.userAgentData?.platform ?? navigator.platform); }
```

## Usage

```javascript
// Headless Chromium on Linux:
isApplePlatform(); // → false
isApplePlatform(); // e.g. true on a Mac, an iPhone or an iPad
```

Lines marked → were executed in headless Chromium against the markup above, and each result was compared with the value shown. Lines marked e.g. are illustrative.

## Limits

- navigator.platform is deprecated, and iPadOS reports "MacIntel" in desktop mode, so this cannot tell a Mac from an iPad. Chromium’s navigator.userAgentData is read where available.
- Use it for keyboard hints (⌘ versus Ctrl), not for features: detect those directly.

The function does not validate its arguments. Add checks where it receives untrusted input.

## Source and license

Original: https://github.com/phuocng/1loc/blob/14b481cf60dff1620ab1bb99a43b1f68068cdd9b/contents/detect-macos-browser.mdx
Source file (this edition): https://github.com/akamind/1loc/blob/0a77f131b22d2ba3b7ec1728846f900c22821678/contents/detect-macos-browser.mdx
Author: Nguyen Huu Phuoc and original contributors
Contributors: See original repository history
Source commit: 14b481cf60dff1620ab1bb99a43b1f68068cdd9b
Copyright (c) 2020 phuoc-ng
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
Modifications: Reads navigator.userAgentData where available; platform limits documented. Executed in Chromium. Original MDX retained as inert source evidence.
