
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A collection of React hooks for detecting device type, network status, battery status, and more.
A comprehensive collection of React hooks for building Progressive Web Apps (PWAs). Easily detect device types, network status, battery levels, geolocation, and more to enhance your web applications.
Install use-is-pwa
using npm or yarn:
npm install use-is-pwa
# or
yarn add use-is-pwa
Import the hooks you need in your React component:
import { useIsMobile, useNetworkStatus, useBatteryStatus } from 'use-is-pwa';
function MyComponent() {
const { isMobile } = useIsMobile();
const isOnline = useNetworkStatus();
const { level, charging } = useBatteryStatus();
return (
<div>
<h1>{isMobile ? 'Mobile View' : 'Desktop View'}</h1>
<p>{isOnline ? 'Online' : 'Offline'}</p>
<p>Battery Level: {Math.round(level * 100)}%</p>
<p>{charging ? 'Charging' : 'Not Charging'}</p>
</div>
);
}
Detects if the device is mobile based on screen width.
const { isMobile, width } = useIsMobile(768);
breakpoint
(optional): Width threshold for mobile detection (default: 768px){ isMobile: boolean, width: number }
Monitors the device's online/offline status.
const isOnline = useNetworkStatus();
boolean
Provides real-time battery information.
const { level, charging } = useBatteryStatus();
{ level: number, charging: boolean }
Tracks the user's current location.
const { location, error } = useGeolocation();
{ location: { latitude: number, longitude: number } | null, error: string | null }
Determines the type of device being used.
const deviceType = useDeviceType();
'mobile' | 'tablet' | 'desktop'
Detects the current screen orientation.
const orientation = useOrientation();
'portrait' | 'landscape'
Provides current screen dimensions.
const { width, height } = useScreenSize();
{ width: number, height: number }
Determines if the device supports touch input.
const isTouchDevice = useTouchOrClick();
boolean
Checks if a media query matches the current environment.
const matches = useMediaQuery('(min-width: 768px)');
query
: CSS media query stringboolean
Detects if a screen reader is active.
const { isScreenReader } = useAccessibility();
{ isScreenReader: boolean }
Provides methods to lock and unlock screen orientation.
const { lockOrientation, unlockOrientation } = useOrientationLock();
{ lockOrientation: () => void, unlockOrientation: () => void }
Detects if the app is running as a Progressive Web App.
const isPWA = useIsPWA();
boolean
We welcome contributions to use-is-pwa
! Please follow these steps:
git checkout -b feature/your-feature-name
git commit -m 'Add some feature'
git push origin feature/your-feature-name
For major changes, please open an issue first to discuss what you would like to change.
FAQs
A collection of React hooks for detecting device type, network status, battery status, and more.
The npm package use-is-pwa receives a total of 0 weekly downloads. As such, use-is-pwa popularity was classified as not popular.
We found that use-is-pwa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.