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

@divergent-development/react-device-detector

v1.0.0

Published

Ultimate React hook for detecting devices, browsers, and platforms

Readme

npm install react-device-detector

EXAMPLE:

import useDeviceDetector from 'react-device-detector';

function MyComponent() { const device = useDeviceDetector();

return ( {device.isIPhone && This is an iPhone} {device.isAndroidTablet && This is an Android tablet} {device.isDesktop && This is a desktop computer} ); }

All Available Properties The hook returns an object with these detection properties:

Device Type Categories Property Description

isMobile True for all mobile phones isTablet True for all tablets isDesktop True for desktop/laptop devices

Platform Detection Property Description

isIOS True for any iOS device isAndroid True for any Android device isWindowsPhone True for Windows phones

Apple Device Specifics Property Description

isIPhone True for iPhones isIPad True for iPads (including iPadOS 13+) isIPod True for iPod Touch

Android Device Specifics Property Description

isAndroidPhone True for Android phones isAndroidTablet True for Android tablets

Other Devices Property Description

isKindle True for Kindle devices isSilk True for Amazon Silk browser isPlaybook True for Blackberry Playbook

Browser Detection Property Description

isChrome Chrome/Chromium browsers isFirefox Firefox browser isSafari Safari (not Chrome on iOS) isEdge Microsoft Edge isOpera Opera browser isIE Internet Explorer


  1. Platform-Specific Components

function PlatformSpecificComponent() { const { isIPhone, isAndroidPhone, isDesktop } = useDeviceDetector();

if (isIPhone) return ; if (isAndroidPhone) return ; if (isDesktop) return ;

return ; }


  1. Responsive Layout with Device Detection

function ResponsiveLayout() { const device = useDeviceDetector();

return ( <div className={app-container ${device.isMobile ? 'mobile' : ''} ${device.isTablet ? 'tablet' : ''}}> {device.isMobile && } {device.isTablet && } {device.isDesktop && }

  <main>
    {device.isIPad && <IPadOptimizedContent />}
    {device.isAndroidTablet && <AndroidTabletContent />}
    {device.isDesktop && <DesktopContent />}
  </main>
</div>

); }


  1. Browser-Specific Feature Detection

function BrowserFeatures() { const { isChrome, isFirefox, isSafari } = useDeviceDetector();

return ( {isChrome && } {isFirefox && } {isSafari && }

  {!isChrome && !isFirefox && !isSafari && (
    <p>Please use Chrome, Firefox or Safari for best experience</p>
  )}
</div>

); }


  1. Device-Specific Analytics

function AnalyticsTracker() { const device = useDeviceDetector();

useEffect(() => { if (device.isIPhone) { trackEvent('iPhone User'); } else if (device.isAndroidPhone) { trackEvent('Android Phone User'); } // etc... }, [device]);

return ; }


Performance Considerations

Efficient Re-rendering: The hook only triggers re-renders when device characteristics actually change Resize Optimization: Device detection is debounced during window resizing SSR Compatible: Safely falls back to default values during server-side rendering


TypeScript Support The package includes full TypeScript type definitions. Example with TypeScript:

import useDeviceDetector from 'react-advanced-device-detector';

interface DeviceProps { device: ReturnType; }

const DeviceInfo: React.FC = ({ device }) => (

function App() { const device = useDeviceDetector(); return ; }


Troubleshooting If you encounter any issues:

Check user agent: Log navigator.userAgent to verify detection

useEffect(() => { console.log('User Agent:', navigator.userAgent); }, []);


Verify hook output:

function DebugComponent() { const device = useDeviceDetector(); console.log('Device Info:', device); return null; }