Skip to content

Installation

Requirements

EnvironmentMinimum version
Node.js18+
React17+ (optional — only needed for os-detect/react)
Vue3+ (optional — only needed for os-detect/vue)

No runtime dependencies otherwise — the core entry point works in any browser or Node.js environment with zero installs beyond the package itself.

Installation

bash
npm install os-detect

React hooks (optional peer dependency):

bash
npm install react@>=17

Vue composables (optional peer dependency):

bash
npm install vue@>=3

CDN

A prebuilt UMD bundle is available via unpkg and jsDelivr — no build step required.

html
<script src="https://unpkg.com/os-detect/dist/index.umd.js"></script>
<script>
  console.log(OsDetect.getOS())
  console.log(OsDetect.detectIsIOS())
  console.log(OsDetect.isMobileDevice())

  OsDetect.detectIsWindows11().then((isWin11) => {
    console.log('Windows 11:', isWin11)
  })
</script>

The global name is OsDetect. All functions from the core entry point are exposed on it.

Quick start

ts
import { getOS, detectIsIOS, detectIsWindows, isMobileDevice } from 'os-detect'

console.log(getOS()) // 'windows' | 'macos' | 'ios' | 'android' | 'linux' | 'chromeos' | 'unknown'
console.log(detectIsIOS()) // true on iPhone / iPad
console.log(detectIsWindows()) // true on Windows desktop
console.log(isMobileDevice()) // true on iOS or Android

All functions are synchronous and cached — safe to call on every render or in any reactive context.