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

@shaaz1000/rn-device-utils

v1.0.0

Published

Comprehensive device utilities for React Native including scaling, device info, keyboard handling, and platform-specific helpers

Downloads

5

Readme

@shaaz1000/rn-device-utils

A comprehensive utility package for React Native applications that handles device information, responsive design, keyboard management, and platform-specific features.

Features

  • 📱 Complete device information and detection
  • 📐 Responsive scaling utilities
  • ⌨️ Advanced keyboard handling
  • 🔍 Notch & Dynamic Island detection
  • 💫 Safe area utilities
  • 📏 Window dimension hooks
  • 🎯 Platform-specific utilities
  • 🔄 Orientation management
  • 📦 Version management
  • 📱 Dynamic Island support

Installation

# Using npm
npm install @shaaz1000/rn-device-utils

# Using yarn
yarn add @shaaz1000/rn-device-utils

Core Features

1. Device Information

import { DeviceInfoManager } from '@shaaz1000/rn-device-utils';

const deviceInfo = DeviceInfoManager.getInstance();

// Get device details
const info = deviceInfo.getDeviceInfo();
console.log(info.isTablet); // true/false
console.log(info.hasNotch); // true/false
console.log(info.hasDynamicIsland); // true/false

// Check if device has any display cutout
const hasCutout = deviceInfo.hasDisplayCutout();

// Get status bar height considering cutouts
const statusBarHeight = deviceInfo.getStatusBarHeight();

2. Responsive Scaling

import { 
  scaleWidth, 
  scaleHeight, 
  moderateScale,
  horizontalScale,
  verticalScale,
  pixelsToDp,
  dpToPixels,
  getPixelRatio,
  getFontScale,
  scaleText 
} from '@shaaz1000/rn-device-utils';

const styles = StyleSheet.create({
  container: {
    width: scaleWidth(300),
    height: scaleHeight(200),
    padding: moderateScale(10),
    marginHorizontal: horizontalScale(20),
    marginVertical: verticalScale(10)
  },
  text: {
    fontSize: scaleText(16)
  }
});

// Convert measurements
const dpValue = pixelsToDp(100);
const pixelValue = dpToPixels(50);
const devicePixelRatio = getPixelRatio();
const systemFontScale = getFontScale();

3. Keyboard Management

import { useKeyboard, KeyboardManager } from '@shaaz1000/rn-device-utils';

function MyComponent() {
  const { 
    keyboardHeight, 
    keyboardVisible, 
    dismissKeyboard,
    keyboardAnimationDuration,
    isAvoidingView,
    defaultBehavior 
  } = useKeyboard();

  // Using KeyboardManager directly
  KeyboardManager.addShowListener((event) => {
    const height = KeyboardManager.getKeyboardHeight(event);
    const duration = KeyboardManager.getAnimationDuration(event);
  });

  return (
    <KeyboardAvoidingView 
      behavior={defaultBehavior}
      enabled={isAvoidingView}
      style={{ paddingBottom: keyboardVisible ? keyboardHeight : 0 }}
    >
      {/* Your content */}
    </KeyboardAvoidingView>
  );
}

4. Safe Area & Notch/Dynamic Island Handling

import { useSafeArea, NotchHelper } from '@shaaz1000/rn-device-utils';

function MyComponent() {
  const safeArea = useSafeArea();
  const displayCutout = NotchHelper.getDisplayCutout();

  // Get specific display cutout info
  const { type, topInset, bottomInset } = displayCutout;
  const isNotch = type === 'notch';
  const isDynamicIsland = type === 'dynamicIsland';

  // Get safe padding
  const padding = NotchHelper.getSafePadding();

  return (
    <View style={{
      paddingTop: safeArea.top,
      paddingBottom: safeArea.bottom,
      // Handle notch or dynamic island
      marginTop: displayCutout.topInset
    }}>
      {/* Your content */}
    </View>
  );
}

5. Responsive Design Hook

import { useResponsive } from '@shaaz1000/rn-device-utils';

function MyComponent() {
  const responsive = useResponsive();

  const fontSize = responsive.getFontSize(16);
  const isSmall = responsive.isSmallDevice;
  const percentage = responsive.getPercentage(50); // 50% of screen width

  // Get responsive values based on screen size
  const padding = responsive.getValue(10, 15, 20); // small, medium, large devices

  return (
    <View style={{
      width: responsive.widthScale(300),
      padding: responsive.moderateScale(10)
    }}>
      <Text style={{ fontSize }}>
        {isSmall ? 'Small Device' : 'Regular Device'}
      </Text>
    </View>
  );
}

6. Platform Utilities

import { PlatformManager, VersionManager } from '@shaaz1000/rn-device-utils';

const platform = PlatformManager.getInstance();

// Platform-specific values
const padding = platform.select({
  ios: 20,
  android: 16,
  default: 10
});

// Version checking
if (platform.isAtLeastiOS('15.0')) {
  // Use iOS 15+ features
}

// Version comparison
const isNewer = VersionManager.compareVersions('1.2.0', '1.1.0'); // Returns 1
const isSupported = VersionManager.isAtLeast('15.0');

// Get platform info
const info = platform.getPlatformInfo();
console.log(info.isTablet, info.isTV, info.majorVersion);

7. Orientation Management

import { useOrientation, OrientationManager } from '@shaaz1000/rn-device-utils';

function MyComponent() {
  const orientation = useOrientation();
  
  // Or use the manager directly
  const isPortrait = OrientationManager.isPortrait();
  const dimensions = OrientationManager.getDimensionsForOrientation();

  return (
    <View style={{
      flexDirection: orientation === 'portrait' ? 'column' : 'row',
      width: dimensions.width,
      height: dimensions.height
    }}>
      {/* Your content */}
    </View>
  );
}

8. Window Dimensions

import { useWindowDimensions } from '@shaaz1000/rn-device-utils';

function MyComponent() {
  const { 
    width,
    height,
    scale,
    fontScale,
    isPortrait,
    isLandscape 
  } = useWindowDimensions();

  return (
    <View style={{
      width: isPortrait ? '100%' : '50%',
      height: height * 0.5,
      fontSize: 16 * fontScale
    }}>
      {/* Your content */}
    </View>
  );
}

API Reference

Hooks

  • useKeyboard() - Keyboard state and dimensions
  • useSafeArea() - Safe area insets
  • useResponsive() - Responsive design utilities
  • useOrientation() - Device orientation
  • useWindowDimensions() - Screen dimensions and orientation

Managers

  • DeviceInfoManager - Device information and capabilities
  • PlatformManager - Platform-specific utilities
  • KeyboardManager - Keyboard event handling
  • OrientationManager - Orientation utilities
  • NotchHelper - Notch and Dynamic Island detection
  • VersionManager - Version comparison and checking

Scaling Utilities

  • scaleWidth(dimension: number) - Scale width dimension
  • scaleHeight(dimension: number) - Scale height dimension
  • horizontalScale(size: number) - Scale size horizontally
  • verticalScale(size: number) - Scale size vertically
  • moderateScale(dimension: number, factor = 0.5) - Moderate scaling for better UX
  • pixelsToDp(pixels: number) - Convert pixels to DP
  • dpToPixels(dp: number) - Convert DP to pixels
  • getPixelRatio() - Get device pixel ratio
  • getFontScale() - Get font scale
  • scaleText(size: number) - Scale text size

Platform Support

  • iOS 11.0 and above
  • Android API level 21 and above
  • Supports both phones and tablets
  • Special handling for notched devices and Dynamic Island
  • iPhone models support:
    • iPhone X through iPhone 14 Pro Max (Notch)
    • iPhone 14 Pro through iPhone 16 Pro Max (Dynamic Island)

Contributing

Contributions are welcome! Please read our contributing guide to get started.

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see the LICENSE file for details

Author

Shaaz Khan

Support

For support, issues, or feature requests, please file an issue in the GitHub repository.