npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@confidential-nt/use-media-query

v1.1.0

Published

A React hook for media queries

Downloads

23

Readme

useMediaQuery

React에서 미디어 쿼리를 기반으로 반응형 UI를 쉽게 구현할 수 있도록 도와주는 커스텀 훅입니다.


설치

npm install @confidential-nt/use-media-query

사용 예제

import { useMediaQuery } from '@confidential-nt/use-media-query';

function Component() {
  const isDesktop = useMediaQuery('(min-width:1024px)');

  if (isDesktop) {
    // 데스크톱 전용 UI 렌더링
  }
}

확장된 API 사용 예시:

const isMobile = useMediaQuery({
  below: 'md',
});
const isTablet = useMediaQuery({
  between: ['md', 'lg'],
});
const isDesktop = useMediaQuery({
  above: 'lg',
});

사용법

const matches = useMediaQuery(query);

매개변수

| 이름 | 타입 | 설명 | | ------- | ------------------------------------------------------------------------------------------ | ---------------------------------------- | | query | string \| { above?: Breakpoint; below?: Breakpoint; between?: [Breakpoint, Breakpoint] } | 미디어 쿼리 조건 (문자열 또는 객체 기반) |

Breakpoint 종류

| 값 | 해상도 (px 기준) | | ---- | ---------------- | | sm | 640 | | md | 768 | | lg | 1024 | | xl | 1280 |

예시 조합

| 입력 형태 | 실제 쿼리 문자열 | | --------------------------- | -------------------------------------------- | | { above: 'md' } | (min-width: 768px) | | { below: 'lg' } | (max-width: 1024px) | | { between: ['md', 'xl'] } | (min-width: 768px) and (max-width: 1280px) |


키워드 사용 시 주의사항

  • above | belowbetween동시에 사용할 수 없습니다.
    • ✅ 허용: {above: 'md', below: 'lg'}
    • ❌ 에러: {above: 'md', between: ['md', 'lg']}
  • 문자열 쿼리를 직접 넣는 방식과 객체 기반 방식은 동일하게 동작합니다.

SSR 사용 시 주의사항

해당 훅은 브라우저의 window.matchMedia를 사용합니다.
따라서 SSR 환경에서는 기본값으로 false를 반환합니다.

typeof window !== "undefined" 체크가 포함되어 있어 에러는 발생하지 않지만,
초기 렌더링에서 false가 나올 수 있음에 유의해주세요.


FAQ[선택]

Q. 왜 above, below, between를 동시에 사용하면 안 되나요?

A. 혼동되는 조합은 내부 로직의 명확성을 떨어뜨릴 수 있고 예측 불가능한 동작이 생깁니다.
따라서 한 번에 하나의 조건만 사용하는 것을 권장합니다.


기여

버그 제보, 기능 제안, PR 모두 환영합니다! (가이드가 있다면 링크로 보여주기)


라이선스

MIT (링크 포함시키기)