Spaces:
Paused
Paused
File size: 472 Bytes
5db682b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import { useEffect, useState } from 'react'
export default function useDeviceOS(): string {
const [os, setOS] = useState('')
useEffect(() => {
const userAgent = window.navigator.userAgent
if (userAgent.indexOf('Windows') > -1) {
setOS('windows')
} else if (userAgent.indexOf('Mac OS') > -1) {
setOS('mac')
} else if (userAgent.indexOf('Linux') > -1) {
setOS('linux')
} else {
setOS('other')
}
}, [])
return os
}
|