use-os

Get user os
Import

Usage

Hook detects user os. Possible values are: undetermined, macos, ios, windows, android, linux. If os can be identified as well as 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(): 'undetermined' | 'macos' | 'ios' | 'windows' | 'android' | 'linux';
Build fully functional accessible web applications faster than ever
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback