
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-device-meta-hook
Advanced tools
A lightweight React hook that detects the user's browser, operating system, device type (mobile, tablet, desktop), screen orientation, and resolution. It automatically adds meaningful CSS classes to the `<html>` element, enabling responsive design and con
🧠 React hook to detect browser, OS, device type, orientation, resolution, and viewport heights, and apply them as CSS classes to the
<html>element. Ideal for responsive design and adaptive UI development.
npm install react-detect-device-info
# or
yarn add react-detect-device-info
useDeviceDetect is a lightweight utility hook for React applications that:
dvh, lvh, svh<html> element.Responsive design often depends on breakpoints, media queries, or JS-based logic. This hook enables:
import React from "react";
import { useDeviceDetect } from "react-detect-device-info";
function App() {
useDeviceDetect((info) => {
console.log("Device Info:", info);
});
return <div>Hello world</div>;
}
export default App;
<html> Classes Example<html class="chrome windows desktop landscape w1440 h900"></html>
You can now write CSS based on these classes:
.desktop .header {
padding: 20px;
}
.ios .button {
font-size: 16px;
}
.w375.h812 {
font-size: 14px;
}
useDeviceDetect(callback?)| Parameter | Type | Description |
|---|---|---|
callback | (info: DeviceInfo) => void | Optional. Receives detailed info object as argument. |
DeviceInfo Object Shapeinterface DeviceInfo {
browser: {
name: string;
version: string;
};
os: string;
deviceType: "mobile" | "tablet" | "desktop";
orientation: "portrait" | "landscape";
resolution: {
width: number;
height: number;
};
viewportHeights: {
dvh: number; // dynamic viewport height
lvh: number; // largest possible viewport height
svh: number; // smallest viewport height (when address bar shown)
};
}
dvh, lvh, and svh to deal with mobile browser toolbars (keyboard, address bar).<html> classes like .android, .firefox, .tablet, you can test layouts more easily..ios.safari .footer {
padding-bottom: 80px;
}
.android .page {
height: 100svh; /* Safe height */
}
.landscape .header {
flex-direction: row;
}
This hook was inspired by the need for responsive CSS control without bloated JS logic. Special thanks to the growing community focused on adaptive UX/UI.
FAQs
A lightweight React hook that detects the user's browser, operating system, device type (mobile, tablet, desktop), screen orientation, and resolution. It automatically adds meaningful CSS classes to the `<html>` element, enabling responsive design and con
We found that react-device-meta-hook demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.