Created
January 20, 2021 19:19
-
-
Save bobdobbalina/4c3fcaa00f4cbb412257bf70839f5c10 to your computer and use it in GitHub Desktop.
Javascript: Detect device type
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 detectDeviceType = () => | |
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) | |
? 'mobile' | |
: 'desktop'; | |
detectDeviceType(); // "mobile" or "desktop" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment