is-device-mobile

1.0.4 • Public • Published

Is Device Mobile?

Background

We 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.

Installation

Install the component in your project with the following command:

yarn add is-device-mobile

Usage

import { isMobile } from 'is-device-mobile';
 
const getDeviceType = () => {
  return isMobile(window) ? "mobile" : "desktop";
};

In order to work, isMobile requires window as argument.

Resources

This utility follows Mozilla browser detection guidelines

Package Sidebar

Install

npm i is-device-mobile

Weekly Downloads

4

Version

1.0.4

License

MIT

Unpacked Size

2.14 kB

Total Files

2

Last publish

Collaborators

  • 7michele7