A utility to determine whether the client's device is mobile or not
npm install is-device-mobileWe often need to change _functionality_ / _behavior_ / _layout_ whether the client's device is mobile or not.
This tiny utility will help determining it checking client's maxTouchPoints (or msMaxTouchPoints), (pointer:coarse) Media Queries, orientation or, as last resort, userAgent.
Install the component in your project with the following command:
``Bash`
yarn add is-device-mobile
`JS
import { isMobile } from 'is-device-mobile';
const getDeviceType = () => {
return isMobile(window) ? "mobile" : "desktop";
};
`
In order to work, isMobile requires window` as argument.
This utility follows Mozilla browser detection guidelines