# usedevice

> React Hook for detect device properties

Latest version **1.0.18** (published 2019-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install usedevice
pnpm add usedevice
yarn add usedevice
bun add usedevice
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.18 |
| Published | 2019-06-20 |
| First published | 2019-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | ChuckGonzalez |
| Maintainers | chuckgonzalez |
| Keywords | React, Hooks, Device, Resize, Browser |

## Links

- npm: https://www.npmjs.com/package/usedevice
- Repository: https://github.com/redube/useDevice
- Homepage: https://github.com/redube/useDevice#readme
- Issues: https://github.com/redube/useDevice/issues
- npm.io page: https://npm.io/package/usedevice

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.18 (latest) — 2019-06-20
- 1.0.17 — 2019-06-18
- 1.0.16 — 2019-06-18
- 1.0.15 — 2019-06-18
- 1.0.14 — 2019-06-18
- 1.0.13 — 2019-06-18
- 1.0.12 — 2019-06-18
- 1.0.11 — 2019-02-18
- 1.0.10 — 2019-02-18
- 1.0.9 — 2019-02-18
- 1.0.7 — 2019-02-18
- 1.0.6 — 2019-02-18
- 1.0.5 — 2019-02-18
- 1.0.4 — 2019-02-18
- 1.0.2 — 2019-02-08
- … 2 more at https://npm.io/package/usedevice/versions

## README

# useDevice

React Hook for detect device properties

### Install

```
npm install -S usedevice
```

### Usage

```
import useDevice from 'usedevice';

const Component = () => {
  const device = useDevice();

  return (
    <section>...</section>
  );
};
```

Device wil have the following properties

```
{
  browser: "Chrome",
  device: "desktop",
  height: 438,
  isIE: false,
  isMobileAgent: false,
  isOrientationCapable: true,
  isTouch: false,
  orientation: "landscape",
  os: "Mac OS X",
  screenSize: "desktop",
  version: "10_11_5",
  width: 1292,
}
```

In every resize the hook will execute and return a new object with the new properties

### Breakpoints

You can pass an array of breakpoints to the hook

```
import useDevice from 'usedevice';

const breakpoints = [
  {name: 'miniphone', min: 0, max: 320},
  {name: 'phone', min: 320, max: 640},
  {name: 'tablet', min: 640, max: 1080},
  {name: 'desktop', min: 1080, max: Infinity},
];

const Component = () => {
  const device = useDevice(breakpoints);

  return (
    <section>...</section>
  );
};
```

In the constant device you will receive the prop breakpoint with the name of the breakpoint matching, if multiple breakpoints match the name is from the first match.

```
{
  breakpoint: 'desktop'
  width: 1292,
}

{
  breakpoint: 'phone'
  width: 540,
}
```

---
_Source: https://npm.io/package/usedevice · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
