Vue Browser Detect Plugin

0.1.18 · active · verified Sun Apr 19

Vue Browser Detect Plugin is a lightweight and straightforward utility for Vue.js applications, enabling developers to identify the user's browser, its version, and the full user-agent string. It exposes browser detection flags (e.g., `isIE`, `isChrome`, `isFirefox`, `isSafari`, `isEdge`, `isOpera`, `isChromeIOS`, `isIOS`) and detailed meta-information (`name`, `version`, `ua`) directly via `vm.$browserDetect`. The current stable version is 0.1.18, and releases appear to be on an as-needed basis rather than a fixed cadence, focusing on adding new browser checks or minor enhancements. Its key differentiator is its simplicity and direct integration into Vue's instance, offering a non-intrusive way to adapt UI/UX based on browser capabilities without heavy external dependencies.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install `vue-browser-detect-plugin`, integrate it into a Vue application using `Vue.use()`, and access the `$browserDetect` object from within a Vue component to display various browser-specific properties and metadata.

npm install vue-browser-detect-plugin

// main.js or main.ts
import Vue from 'vue';
import App from './App.vue';
import browserDetect from 'vue-browser-detect-plugin';

Vue.use(browserDetect);

new Vue({
  render: h => h(App),
}).$mount('#app');

// In a Vue component (e.g., App.vue)
<template>
  <div>
    <h1>Browser Detection Demo</h1>
    <p>Is Chrome: {{ $browserDetect.isChrome }}</p>
    <p>Is Firefox: {{ $browserDetect.isFirefox }}</p>
    <p>Is iOS: {{ $browserDetect.isIOS }}</p>
    <p>Browser Name: {{ $browserDetect.meta.name }}</p>
    <p>Browser Version: {{ $browserDetect.meta.version }}</p>
    <p>User Agent: {{ $browserDetect.meta.ua }}</p>
    <div v-if="$browserDetect.isIE" class="ie-warning">
      You are using Internet Explorer, which may have limited support.
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  mounted() {
    console.log('Browser details:', this.$browserDetect);
  }
};
</script>

<style>
.ie-warning {
  color: red;
  font-weight: bold;
}
</style>

view raw JSON →