nuxt-ua
nuxt-ua 
UserAgent detector using Platform.js for Nuxt.
Install
npm install --save nuxt-ua
Usage
This module is compatible with Nuxt 2, Nuxt 3 and Nuxt-bridge.
Add 'nuxt-ua' to your modules array in the nuxt.config.ts file:
modules: [
// other modules...
'nuxt-ua',
]
Nuxt 2 types
If you are using TypeScript in a Nuxt2 project, please add nuxt-ua/types to your tsconfig.json file to inject $ua into the Context:
{
"compilerOptions": {
// ..
"types": [
"@nuxt/types",
"@types/node",
"nuxt-ua/types"
]
}
}
Then, you can use the `$ua` object:
```html
<template>
<main>
{{ $ua.is.chrome ? 'This is Chrome' : 'This is not Chrome' }}
</main>
</template>
<script lang="ts">
import Vue from 'vue';
import { Context } from '@nuxt/vue-app/types';
export default Vue.extend({
fetch(context: Context) {
console.log(context.$ua);
}
});
</script>
API
$ua.platform
Returns a Platform object.
$ua.is.chrome
Returns true if the UserAgent is Chrome.
$ua.is.firefox
Returns true if the UserAgent is Firefox.
$ua.is.safari
Returns true if the UserAgent is Safari.
$ua.is.ie
Returns true if the UserAgent is Internet Explorer.
$ua.is.edge
Returns true if the UserAgent is Microsoft Edge.
$ua.is.opera
Returns true if the UserAgent is Opera.
$ua.is.android
Returns true if the UserAgent is Android.
$ua.is.ios
Returns true if the UserAgent is iOS.
$ua.is.macos
Returns true if the UserAgent is macOS.
$ua.is.windows
Returns true if the UserAgent is Windows.
$ua.is.linux
Returns true if the UserAgent is Linux.
Development
- Install the development dependencies
npm ci
- Initialize the Nuxt playground
npm run dev:prepare
- Run the development environment
npm run dev
- Add or modify the tests and ensure that tests are passing
npm test
License
Related Packages
One utility function for module authors to define compiler constants for all bui...
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 2.0.0 | ^3.0 | MIT | |
| 1.0.8 | ^2.0.0 | MIT | |
| 1.0.7 | ^2.0.0 | MIT | |
| 1.0.6 | ^2.0.0 | MIT | |
| 1.0.5 | ^2.0.0 | MIT | |
| 1.0.4 | ^2.0.0 | MIT | |
| 1.0.3 | ^2.0.0 | MIT | |
| 1.0.2 | ^2.0.0 | MIT | |
| 1.0.1 | ^2.0.0 | MIT | |
| 1.0.0 | ^2.0.0 | MIT | |
| 0.13.0 | ^2.0.0 | MIT | |
| 0.12.1 | ^2.0.0 | MIT | |
| 0.12.0 | ^2.0.0 | MIT | |
| 0.11.0 | ^2.0.0 | MIT | |
| 0.10.0 | ^2.0.0 | MIT | |
| 0.9.0 | ^2.0.0 | MIT | |
| 0.8.0 | ^2.0.0 | MIT | |
| 0.7.0 | ^2.0.0 | MIT | |
| 0.6.0 | ^2.0.0 | MIT | |
| 0.5.0 | ^2.0.0 | MIT | |
| 0.4.0 | ^2.0.0 | MIT | |
| 0.3.0 | ^2.0.0 | MIT | |
| 0.2.0 | ^2.0.0 | MIT | |
| 0.1.0 | ^2.0.0 | MIT | |
| 0.0.0 | ^2.0.0 | MIT |