https://github.com/haldarmahesh/use-mobile-detect-hook
React hook to detect the device type
https://github.com/haldarmahesh/use-mobile-detect-hook
hooks javascript react reactjs
Last synced: about 1 year ago
JSON representation
React hook to detect the device type
- Host: GitHub
- URL: https://github.com/haldarmahesh/use-mobile-detect-hook
- Owner: haldarmahesh
- License: mit
- Created: 2018-11-02T19:54:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T18:36:49.000Z (over 3 years ago)
- Last Synced: 2025-04-13T03:14:24.724Z (about 1 year ago)
- Topics: hooks, javascript, react, reactjs
- Language: JavaScript
- Homepage:
- Size: 259 KB
- Stars: 82
- Watchers: 2
- Forks: 15
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/js/use-mobile-detect-hook)
# use-mobile-detect-hook
React hook to detect the device type. This hook is able to detect mobile, desktop, android or iOS device.
# Installing
```bash
npm install use-mobile-detect-hook
```
```bash
yarn add use-mobile-detect-hook
```
# Demo
Follow [this link](http://www.maheshhaldar.com/demo-use-mobile-detect-hook/) to check the demo.
# Usage
```javascript
import useMobileDetect from 'use-mobile-detect-hook';
function MyComponent = (props) => {
const detectMobile = useMobileDetect();
return (
is Mobile: { detectMobile.isMobile() }
is Desktop: { detectMobile.isDesktop() }
is Android: { detectMobile.isAndroid() }
is iOS: { detectMobile.isIos() }
);
};
```
# Contributing
If you have any new suggestions, new features, bug fixes, etc. please contribute by raising pull request on the [repository](https://github.com/haldarmahesh/use-mobile-detect-hook).
If you have any issue with the `use-mobile-detect-hook`, open an issue on [Github](https://github.com/haldarmahesh/use-mobile-detect-hook).