/use-mobile-detect-hook

React hook to detect the device type

Primary LanguageJavaScriptMIT LicenseMIT

npm version

use-mobile-detect-hook

React hook to detect the device type. This hook is able to detect mobile, desktop, android or iOS device.

Installing

npm install use-mobile-detect-hook
yarn add use-mobile-detect-hook

Demo

Follow this link to check the demo.

Usage

import useMobileDetect from 'use-mobile-detect-hook';

function MyComponent  = (props) => {
  const detectMobile = useMobileDetect();

  return (
      <div>
        is Mobile: { detectMobile.isMobile() } <br/>
        is Desktop: { detectMobile.isDesktop() } <br/>
        is Android: { detectMobile.isAndroid() } <br/>
        is iOS: { detectMobile.isIos() }
      </div>
  );
};

Contributing

If you have any new suggestions, new features, bug fixes, etc. please contribute by raising pull request on the repository.

If you have any issue with the use-mobile-detect-hook, open an issue on Github.