react-use-platform
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

React use platform npm npm type definitions

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'

Package Sidebar

Install

npm i react-use-platform

Weekly Downloads

194

Version

1.0.0

License

ISC

Unpacked Size

13 kB

Total Files

12

Last publish

Collaborators

  • onset