Last active
July 19, 2025 10:05
-
-
Save tzwel/43a1c9a954062880251af17743a24f22 to your computer and use it in GitHub Desktop.
Is phone? Reliable detection of mobile devices in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isPhone = navigator?.userAgentData?.mobile || /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) || !window.matchMedia('(hover: hover)').matches && window.innerWidth <= 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment