Skip to content

Commit

Permalink
detect mobile browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfarms committed Nov 27, 2024
1 parent 453b107 commit 163679d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime/platform/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { Platform } from '../platform';

function hasTouchSupport() {
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
}

const browserPlatform: Platform = {
name: 'browser',
os: 'web',
Expand All @@ -12,7 +16,10 @@ const browserPlatform: Platform = {
window.open(url, '_blank');
},

isMobile: false,
isMobile:
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
) || hasTouchSupport(),
isWindows: false,
isProduction: import.meta.env.MODE === 'production',
isBrowser: true,
Expand Down

0 comments on commit 163679d

Please sign in to comment.