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

react-media-query-kit

v1.0.16

Published

React hook and component utility to detect mobile, tablet, desktop, large desktop and TV screen sizes.

Readme

react-media-query-kit

A lightweight and powerful React hook-based utility for responsive design. Easily detect screen types like mobile, tablet, laptop, desktop, large desktop, and TV without writing manual media queries or complex CSS logic.

Features

  • Simple hooks for device detection – Intuitive API for detecting device types
  • Smart breakpoints – From mobile phones to TVs, including laptops
  • Optional Media component – Declarative conditional rendering support
  • Zero dependencies – No CSS or manual media queries required
  • Developer-friendly – Easy to test, extend, and integrate

Installation

npm install react-media-query-kit
# or
yarn add react-media-query-kit

## Usage

### useMedia() Hook

Detect device type as boolean values for flexible conditional logic:

```javascript

import { useMedia } from 'react-media-query-kit';

const MyComponent = () => {
  const {
    isMobile,
    isTablet,
    isLaptop,
    isDesktop,
    isLargeDesktop,
    isTV,
  } = useMedia();

  return (
    <div>
      {isMobile && <p>You're on a Mobile device.</p>}
      {isTablet && <p>You're on a Tablet.</p>}
      {isLaptop && <p>You're on a Laptop.</p>}
      {isDesktop && <p>You're on a Desktop.</p>}
      {isLargeDesktop && <p>You're on a Large Desktop.</p>}
      {isTV && <p>You're on a TV screen.</p>}
    </div>
  );
};

useCurrentDevice() Hook

Get the current device type as a string value:

import React from 'react';
import { useCurrentDevice } from 'react-media-query-kit';

const DeviceLabel = () => {
  const device = useCurrentDevice();
  // Returns: "mobile", "tablet", "laptop", "desktop", "large-desktop", or "tv"

  return <p>Current device: {device}</p>;
};

Media Component

Conditionally render UI components based on device type:

import React from 'react';
import { Media } from 'react-media-query-kit';

const OnlyDesktop = () => (
  <Media device="desktop">
    <p>This is only shown on desktop devices.</p>
  </Media>
);


import { Media } from 'react-media-query-kit';

const OnlyForLaptop = () => (
  <Media device="laptop">
    <p>This content only appears on laptops.</p>
  </Media>
);

Breakpoints

The following breakpoints are used to determine device types:

| Device | Width Range | |----------------|--------------------| | Mobile | ≤ 480px | | Tablet | 481px – 768px | | Laptop | 769px – 1024px | | Desktop | 1025px – 1440px | | Large Desktop | 1441px – 1920px | | TV | ≥ 1921px |

API Reference

useMedia()

Returns an object with boolean properties for each device type:

{
  isMobile: boolean;
  isTablet: boolean;
  isLaptop:boolean;
  isDesktop: boolean;
  isLargeDesktop: boolean;
  isTV: boolean;
}

useCurrentDevice()

Returns the current device type as a string:

"mobile" | "tablet" | "laptop" | "desktop" | "large-desktop" | "tv"

Media Component

Props:

  • device: The target device type for conditional rendering
  • children: React nodes to render when the device matches

License

MIT © Dheerendra Vikram Dixit

Contributing

We welcome contributions! Please feel free to submit issues and pull requests.

Support

If you encounter any issues or have questions, please file an issue on our GitHub repository.