Why donate
API Explorer
Platform Detection

Helpers are built into Quasar to detect the Platform (and its capabilities) within the context of which the code is running.

TIP

Based on your needs, you might also want to check the Style & Identity > Visibility page to see how you can achieve the same effect using CSS alone. This latter method will render your DOM elements or components regardless of platform though, so choose wisely on how you want to handle the performance of your app.

Loading Platform API...

Usage

Usage inside a Vue component JS:

import { useQuasar } from 'quasar'

setup () {
  const $q = useQuasar()

  $q.platform.is.mobile
}

Usage inside a Vue component template:

$q.platform.is.cordova

You must import it when you use it outside of a Vue component :

import { Platform } from 'quasar'

Platform.is by itself returns an object containing details about the current platform. For example when running Chrome on a MacOS desktop machine, Platform.is would return something similar to:

{
  chrome: true,
  desktop: true,
  mac: true,
  name: "chrome",
  platform: "mac",
  version: "70.0.3538.110",
  versionNumber: 70,
  webkit: true
}

Now, let’s say we want to render different components or DOM elements, based on the platform that the code is running under. We want to show something on desktop and something else on mobile. We would proceed like this:

<div v-if="$q.platform.is.desktop">
  I'm only rendered on desktop!
</div>

<div v-if="$q.platform.is.mobile">
  I'm only rendered on mobile!
</div>

<div v-if="$q.platform.is.electron">
  I'm only rendered on Electron!
</div>
Your device



Properties

The following properties are available to the Platform object. It’s not an exhaustive list though. See the API section below for more details.

PropertyTypeMeaning
Platform.is.mobileBooleanIs the code running on a mobile device?
Platform.is.cordovaBooleanIs the code running within Cordova?
Platform.is.capacitorBooleanIs the code running within Capacitor?
Platform.is.nativeMobileBooleanIs the code running within a native mobile wrapper(Cordova/Capacitor)?
Platform.is.nativeMobileWrapperStringName of the native mobile wrapper('cordova', 'capacitor', or undefined)
Platform.is.electronBooleanIs the code running within Electron?
Platform.is.desktopBooleanIs the code running on a desktop browser?
Platform.is.bexBooleanIs the code running in a browser extension?
Platform.is.androidBooleanIs the app running on an Android device?
Platform.is.blackberryBooleanIs the app running on a Blackberry device?
Platform.is.crosBooleanIs the app running on device with the Chrome OS operating system?
Platform.is.iosBooleanIs the app running on an iOS device?
Platform.is.ipadBooleanIs the app running on an iPad?
Platform.is.iphoneBooleanIs the app running on an iPhone?
Platform.is.ipodBooleanIs the app running on an iPod?
Platform.is.kindleBooleanIs the app running on a Kindle device?
Platform.is.linuxBooleanIs the code running on a device with the Linux operating system?
Platform.is.macBooleanIs the code running on a device with the MacOS operating system?
Platform.is.winBooleanIs the code running on a device with the Windows operating system?
Platform.is.winphoneBooleanIs the code running on a Windows Phone device?
Platform.is.playbookBooleanIs the code running on a Blackberry Playbook device?
Platform.is.silkBooleanIs the code running the Kindle Silk browser?
Platform.is.chromeBooleanIs the code running inside the Google Chrome browser?
Platform.is.firefoxBooleanIs the code running inside the Firefox browser?
Platform.is.operaBooleanIs the code running inside the Opera browser?
Platform.is.safariBooleanIs the code running inside the Apple Safari browser?
Platform.is.vivaldiBooleanIs the code running inside the Vivaldi browser?
Platform.is.edgeBooleanIs the code running inside the Microsoft Edge browser?
Platform.is.ieBooleanIs the code running inside the Microsoft Internet Explorer browser?
Platform.is.webkitBooleanIs the code running on Webkit or webkit-based?
Platform.has.touchBooleanIs the code running on a touch capable screen?
Platform.within.iframeBooleanIs the app running within an IFRAME?

TIP

Running on mobile means you can have this code running on a mobile device (phone or tablet) but with a browser, not within a Cordova wrapper.

Note about SSR

When building for SSR, use only the $q.platform form. Alternatively, when on server-side, this is one more example of how you can use it:

import { Platform } from 'quasar'

// you need access to `ssrContext`
function (ssrContext) {
  const platform = process.env.SERVER
    ? Platform.parseSSR(ssrContext)
    : Platform // otherwise we're on client

  // platform is equivalent to the global import as in non-SSR builds
}

The ssrContext is available in @quasar/app-vite Boot File or @quasar/app-webpack Boot File. And also in the @quasar/app-vite preFetch or @quasar/app-webpack preFetch feature, where it is supplied as a parameter.

The reason for all this is that in a client-only app, every user will be using a fresh instance of the app in their browser. For server-side rendering we want the same: each request should have a fresh, isolated app instance so that there is no cross-request state pollution. So Platform needs to be bound to each request separately.