A device detection hook that sees through iPads posing as Macs, Android UAs with stripped model names, and even Samsung DeX.
About
A React hook library that tells you whether the user is on a phone, tablet, or desktop, and which OS they're running. I built it to deal with iPads disguised as Macs, Android UAs with the model name stripped, and hydration errors in Next.js. Detection checks Client Hints, the UA string, and maxTouchPoints, in that order.
Features
All from useDeviceGet device info like type, os, and isMobile, plus screen orientation, in one call.
Tiny, zero-dependency bundleAbout 1.6 kB in total, or about 1.1 kB if you only use useIsMobile.
SSR-safeThe server and the first render share the same defaults, so Next.js doesn't throw a hydration error.
Unmasks disguised iPadsSpots iPads claiming to be Macs using maxTouchPoints and screen size.
Pixel density hookuseDevicePixelRatio keeps up with zoom and scaling changes.
React-free detection enginePass a request's UA to detectDevice and it works in server middleware too.