isMobile.ts 341 B

12345678910
  1. /**
  2. * Checks if the user agent is a mobile device. On browsers that does not support `navigator.userAgentData`,
  3. * fallback to checking the viewport width.
  4. */
  5. export default function isMobile(): boolean {
  6. if ((navigator as any).userAgentData) {
  7. return (navigator as any).userAgentData.mobile;
  8. }
  9. return window.innerWidth < 800;
  10. }