react-use-platform
v1.1.0
Published
React hook to detect client platform.
Downloads
366
Maintainers
Readme
React use platform
React hook to detect client platform.
See it in action at https://filipchalupa.cz/react-use-platform/.
Use this hook to e.g. offer users to download an app from a platform specific store like Google Play, Apple App Store, Microsoft Store.
Installation
npm install react-use-platform
Usage
import { usePlatform } from 'react-use-platform'
const App = () => {
const platform = usePlatform()
return <p>Your platform is {platform}.</p>
}
Without hook
import { getPlatform } from 'react-use-platform'
console.log(`Your platform is ${getPlatform()}.`)
Possible values
type Platform = 'android' | 'ios' | 'windows' | 'mac' | 'unknown'