nuxt-device
Device & responsive detection module for Nuxt.js
7,542
1
| Install | |
|---|---|
npm install nuxt-device |
|
| Latest Version: | 2.1.0 |
| Older releases: | 1 · 2 |
| License: | MIT |
| Last Updated: | Oct 24, 2022 |
| Links: | GitHub · npm |
Maintainer: vmmendozae
nuxt-device
This module injects flags that indicate a device type into the context and the component instance.
See demo on CodeSandbox.
Setup
Add nuxt-device to the dev dependencies using npm to your project.
npm install nuxt-device
Create plugins/device.js
import Vue from 'vue'
import deviceMixins from 'nuxt-device'
Vue.mixin(deviceMixins)
Add it to the plugins section of your nuxt.config:
{
plugins: [
{ src: '@/plugins/device.js' }
],
}
That's it, you can now use it in your Nuxt app ✨
Flags
You can use these flags to detect the device type.
isDesktop
isMobile
isTablet
isMobileOrTablet
isDesktopOrTablet
isIos
isAndroid
isWindows
isMacOS
Usage
Switch a view
<template>
<section>
<div v-if="isDesktop">
Desktop
</div>
<div v-else-if="isTablet">
Tablet
</div>
<div v-else>
Mobile
</div>
</section>
</template>
Of course, you can use it via this in a script.
Change a layout dynamically
export default {
layout: (ctx) => ctx.isMobile ? 'mobile' : 'default'
}
License
Related Packages
nuxt-translation-manager
Simple and easy to use translation manager for nuxt and nuxt-i18n that allows to...
16,873
19
@traum-ferienwohnungen/nuxt-advanced-healthcheck
Module for adding healthcheck urls to a nuxt project
2,621
3
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 2.1.0 | MIT | ||
| 2.0.3 | MIT | ||
| 2.0.2 | MIT | ||
| 2.0.1 | MIT | ||
| 2.0.0 | MIT | ||
| 1.0.24 | MIT | ||
| 1.0.22 | MIT | ||
| 1.0.21 | MIT | ||
| 1.0.20 | MIT | ||
| 1.0.18 | MIT | ||
| 1.0.17 | MIT | ||
| 1.0.16 | MIT | ||
| 1.0.15 | MIT | ||
| 1.0.14 | MIT | ||
| 1.0.13 | <3 | MIT | |
| 1.0.12 | <3 | MIT | |
| 1.0.11 | <3 | MIT | |
| 1.0.10 | MIT | ||
| 1.0.9 | MIT | ||
| 1.0.8 | MIT | ||
| 1.0.7 | MIT | ||
| 1.0.6 | MIT | ||
| 1.0.5 | MIT | ||
| 1.0.4 | MIT | ||
| 1.0.2 | MIT | ||
| 1.0.1 | MIT | ||
| 1.0.0 | MIT |