use-os

Detects user operating system

Import

Usage

use-os returns user's os. Possible values are: undetermined, macos, ios, windows, android, linux. If the OS cannot be identified, for example, during server side rendering undetermined will be returned.

Your os is undetermined

import { useOs } from '@mantine/hooks';

function Demo() {
  const os = useOs();
  return <>Your os is <b>{os}</b></>;
}

OS type

You can import OS union type from @mantine/hooks:

import type { OS } from '@mantine/hooks';

// OS type is 'undetermined' | 'macos' | 'ios' | 'windows' | 'android' | 'linux'

Definition

function getOS(options?: {
  getValueInEffect: boolean;
}):
  | 'undetermined'
  | 'macos'
  | 'ios'
  | 'windows'
  | 'android'
  | 'linux';