# use-matching-media-queries

> A hook for the react library to detect media query matches.

Latest version **1.0.2** (published 2023-02-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install use-matching-media-queries
pnpm add use-matching-media-queries
yarn add use-matching-media-queries
bun add use-matching-media-queries
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-02-17 |
| First published | 2023-02-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | zharinov-nikita |
| Maintainers | zharinov-nikita |
| Keywords | react, react-hooks, match-media, media-queries |

## Links

- npm: https://www.npmjs.com/package/use-matching-media-queries
- Repository: https://github.com/zharinov-nikita/use-matching-media-queries
- Homepage: https://github.com/zharinov-nikita/use-matching-media-queries#readme
- Issues: https://github.com/zharinov-nikita/use-matching-media-queries/issues
- npm.io page: https://npm.io/package/use-matching-media-queries

## 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.2 (latest) — 2023-02-17
- 1.0.1 — 2023-02-17
- 1.0.0 — 2023-02-17

## README

#### Installation

```
npm i use-matching-media-queries
```


#### Using

```ts
import React from 'react'
import { useMatchingMediaQueries } from 'use-matching-media-queries'

const ComponentForSmallDevice = () => {
  const isSmallDevice = useMatchingMediaQueries('(min-width: 576px)')
  return <>{isSmallDevice && <div>Hello - ComponentForSmallDevice</div>}</>
}

const ComponentForMediumDevice = () => {
  const isMediumDevice = useMatchingMediaQueries('(min-width: 768px)')
  return <>{isMediumDevice && <div>Hello - ComponentForMediumDevice</div>}</>
}

const ComponentForLargeDevice = () => {
  const isLargeDevice = useMatchingMediaQueries('(min-width: 992px)')
  return <>{isLargeDevice && <div>Hello - ComponentForLargeDevice</div>}</>
}

export const App = () => {
  return (
    <>
      <ComponentForSmallDevice />
      <ComponentForMediumDevice />
      <ComponentForLargeDevice />
    </>
  )
}
```

#### Media queries

In the hook as an argument, you can pass the string to according to the [documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries).

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