Reference
Architecture
os-detect
│
├── src/utils/platform.ts
│ getUADataPlatform() → navigator.userAgentData.platform (Chrome/Edge)
│ getNodePlatform() → process.platform (Node.js only)
│
├── src/utils/cache.ts
│ memoizeBoolean() → wraps a detector with a one-time cache
│ resetDetectionCache() → clears every cache registered via memoizeBoolean()
│
├── src/detectors/ios.ts detectIsIOS() → UA + maxTouchPoints (iPadOS 13+ aware)
├── src/detectors/macos.ts detectIsMacOS() → UAData / UA / process.platform=darwin
├── src/detectors/android.ts detectIsAndroid() → UAData / UA / process.platform=android
├── src/detectors/chromeos.ts detectIsChromeOS() → UAData / UA (browser only)
├── src/detectors/linux.ts detectIsLinux() → UAData / UA / process.platform=linux
│ (excludes Android and ChromeOS)
├── src/detectors/windows.ts detectIsWindows() → UAData / UA / process.platform=win32
│ detectIsWindows11() → async
│ browser: userAgentData.getHighEntropyValues(['platformVersion'])
│ platformVersion >= 13.0.0 → Windows 11
│ Node.js: import('os').release() build number >= 22000
│
├── src/index.ts (core entry point — re-exports the detectors above, plus:)
│ getOS() → calls detectors in priority order
│ isMobileDevice() → detectIsIOS() || detectIsAndroid()
│ isDesktopDevice() → detectIsMacOS() || detectIsWindows()
│ || detectIsLinux() || detectIsChromeOS()
│ detectIsiOS() → deprecated alias for detectIsIOS()
│
├── src/react.ts (os-detect/react)
│ useOS() → useState(() => getOS())
│ useIsWindows11() → useState(null) + useEffect → detectIsWindows11()
│
└── src/vue.ts (os-detect/vue)
useOS() → readonly(ref(getOS()))
useIsWindows11() → readonly(ref(null)) + onMounted → detectIsWindows11()Bundle size & entry points
| Entry point | Peer deps | Format | Notes |
|---|---|---|---|
os-detect | — | ESM, CJS, UMD | Core — all detection functions and the OS type |
os-detect/react | react >=17 | ESM, CJS | useOS and useIsWindows11 hooks |
os-detect/vue | vue >=3 | ESM, CJS | useOS and useIsWindows11 composables |
All three entry points are listed in package.json exports. The React and Vue adapters add no runtime logic beyond the hooks/composables themselves — they call the same cached core functions.
The package has zero runtime dependencies. React and Vue are optional peer dependencies — you only need them if you use the corresponding entry point.
Migration from v1.x
detectIsiOS() was renamed to detectIsIOS() (capital OS) for consistency with the rest of the API.
The old name still works in v2 but logs a deprecation warning and will be removed in v3.0:
ts
detectIsiOS() // ⚠ deprecated — logs console.warn in all environments
detectIsIOS() // ✓ use this insteadNo other breaking changes between v1 and v2.
License
MIT