use-os

Get user os
Import

Usage

use-os detects user's os. Possible values are: undetermined, macos, ios, windows, android, linux. If 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></>;
}

TypeScript

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';