# nuxt-device

> Device & responsive detection module for Nuxt.js

Latest version **2.1.0** (published 2022-10-24) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2022-10-24 |
| First published | 2022-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Victor Mendoza |
| Maintainers | vmmendozae |
| Keywords | nuxt, nuxtjs, nuxt-module, nuxt-bowser, nuxt-browser, browser-detector, nuxt-browser-detector, device-detector, nuxt-detector, nuxt-device, detector |

## Links

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

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2022-10-24
- 2.0.3 — 2022-10-24
- 2.0.2 — 2022-10-19
- 2.0.1 — 2022-10-19
- 2.0.0 — 2022-10-19
- 1.0.24 — 2022-10-19
- 1.0.22 — 2022-10-19
- 1.0.21 — 2022-10-19
- 1.0.20 — 2022-10-19
- 1.0.18 — 2022-10-19
- 1.0.17 — 2022-10-19
- 1.0.16 — 2022-10-19
- 1.0.15 — 2022-10-19
- 1.0.14 — 2022-10-19
- 1.0.13 — 2022-10-19
- … 12 more at https://npm.io/package/nuxt-device/versions

## README

# nuxt-device

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Standard JS][standard-js-src]][standard-js-href]

This module injects flags that indicate a device type into the context and the component instance.

See [demo on CodeSandbox](https://codesandbox.io/s/nuxt-device-evkf8k).

## Setup

Add `nuxt-device` to the dev dependencies using npm to your project.

```bash
npm install nuxt-device
```

Create `plugins/device.js` 

```js
import Vue from 'vue'
import deviceMixins from 'nuxt-device'

Vue.mixin(deviceMixins)
```

Add it to the `plugins` section of your `nuxt.config`:

```js
{
    plugins: [
      { src: '@/plugins/device.js' }
    ],
}
```

That's it, you can now use it in your [Nuxt](https://nuxtjs.org) app ✨

## Flags

You can use these flags to detect the device type.

```js
isDesktop
isMobile
isTablet
isMobileOrTablet
isDesktopOrTablet
isIos
isAndroid
isWindows
isMacOS
```

## Usage

### Switch a view

```html
<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

```js
export default {
  layout: (ctx) => ctx.isMobile ? 'mobile' : 'default'
}
```

## License

[MIT License](./LICENSE)

<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/dt/nuxt-device.svg?style=flat-square
[npm-version-href]: https://www.npmjs.com/package/nuxt-device

[npm-downloads-src]: https://img.shields.io/npm/v/nuxt-device/latest.svg?style=flat-square
[npm-downloads-href]: https://www.npmjs.com/package/nuxt-device

[circle-ci-src]: https://img.shields.io/circleci/project/github/nuxt-community/device-module.svg?style=flat-square
[circle-ci-href]: https://circleci.com/gh/nuxt-community/device-module

[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/device-module.svg?style=flat-square
[codecov-href]: https://codecov.io/gh/nuxt-community/device-module

[standard-js-src]: https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square
[standard-js-href]: https://standardjs.com

[license-src]: https://img.shields.io/npm/l/nuxt-device.svg?style=flat-square
[license-href]: https://npmjs.com/package/nuxt-device

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