# nuxt-ua

> UserAgent detector using platform for Nuxt

Latest version **2.0.0** (published 2023-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install nuxt-ua
pnpm add nuxt-ua
yarn add nuxt-ua
bun add nuxt-ua
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-03-08 |
| First published | 2019-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 1000ch |
| Maintainers | 1000ch |
| Keywords | nuxt, platform, ua, useragent, vue |

## Links

- npm: https://www.npmjs.com/package/nuxt-ua
- Repository: https://github.com/1000ch/nuxt-ua
- Homepage: https://github.com/1000ch/nuxt-ua#readme
- Issues: https://github.com/1000ch/nuxt-ua/issues
- npm.io page: https://npm.io/package/nuxt-ua

## Dependencies (3)

- [platform](https://npm.io/package/platform.md) ^1.3.6
- [@nuxt/kit](https://npm.io/package/@nuxt/kit.md) ^3.2.3
- [@types/platform](https://npm.io/package/@types/platform.md) ^1.3.4

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-03-08
- 1.0.8 — 2022-03-15
- 1.0.7 — 2021-09-20
- 1.0.6 — 2020-07-14
- 1.0.5 — 2020-04-22
- 1.0.4 — 2019-12-22
- 1.0.3 — 2019-08-14
- 1.0.2 — 2019-08-07
- 1.0.1 — 2019-07-28
- 1.0.0 — 2019-06-04
- 0.13.0 — 2019-05-16
- 0.12.1 — 2019-05-11
- 0.12.0 — 2019-05-11
- 0.11.0 — 2019-05-10
- 0.10.0 — 2019-05-10
- … 10 more at https://npm.io/package/nuxt-ua/versions

## README

# nuxt-ua ![GitHub Actions Status](https://github.com/1000ch/nuxt-ua/workflows/test/badge.svg?branch=main)

> UserAgent detector using [Platform.js](https://github.com/bestiejs/platform.js) for Nuxt.

## Install

```bash
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:

```js
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`](https://nuxtjs.org/api/context/):

```jsonc
{
  "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`](https://www.npmjs.com/package/@types/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

1. Install the development dependencies

```
npm ci
```

2. Initialize the Nuxt playground

```
npm run dev:prepare
```

3. Run the development environment

```
npm run dev
```


4. Add or modify the tests and ensure that tests are passing

```
npm test
```

## License

[MIT](https://1000ch.mit-license.org) © [Shogo Sensui](https://github.com/1000ch)

---
_Source: https://npm.io/package/nuxt-ua · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
