Skip to content

Instantly share code, notes, and snippets.

@dmjcomdem
Last active May 24, 2018 12:47
Show Gist options
  • Save dmjcomdem/d59cdc10623de4d04f6718d2fe65a2e7 to your computer and use it in GitHub Desktop.
Save dmjcomdem/d59cdc10623de4d04f6718d2fe65a2e7 to your computer and use it in GitHub Desktop.
Detects wether the website is being opened in a mobile device or a desktop/laptop.
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