
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
@vueuse/nuxt
Advanced tools
@vueuse/nuxt is a Nuxt.js module that integrates VueUse, a collection of essential Vue Composition Utilities for Vue 2 and 3. It provides a wide range of reactive utilities and composable functions to enhance your Vue.js development experience.
State Management
This feature allows you to easily manage state with localStorage. The `useLocalStorage` function synchronizes a reactive variable with localStorage, making it persistent across page reloads.
```javascript
<script setup>
import { useLocalStorage } from '@vueuse/core'
const name = useLocalStorage('name', 'John Doe')
</script>
<template>
<input v-model="name" placeholder="Enter your name" />
<p>Your name is: {{ name }}</p>
</template>
```
Sensors
This feature provides reactive utilities for various sensors. The `useMouse` function, for example, tracks the mouse position and makes it reactive, allowing you to easily use it in your templates.
```javascript
<script setup>
import { useMouse } from '@vueuse/core'
const { x, y } = useMouse()
</script>
<template>
<p>Mouse position: ({{ x }}, {{ y }})</p>
</template>
```
Network
This feature provides utilities to reactively track network status. The `useOnline` function, for example, allows you to determine if the user is online or offline and react accordingly in your templates.
```javascript
<script setup>
import { useOnline } from '@vueuse/core'
const isOnline = useOnline()
</script>
<template>
<p v-if="isOnline">You are online</p>
<p v-else>You are offline</p>
</template>
```
The `vue-composition-api` package provides a way to use the Vue 3 Composition API in Vue 2 projects. While it offers similar reactive utilities, it does not come with the extensive collection of composable functions that @vueuse/nuxt provides.
Pinia is a state management library for Vue that offers a simpler and more intuitive API compared to Vuex. While it focuses on state management, it does not provide the wide range of reactive utilities that @vueuse/nuxt offers.
This is an add-on of VueUse, which provides better Nuxt integration auto-import capabilities.
Install the vueuse module into your application using nuxi:
npx nuxi@latest module add vueuse
Or use npm:
npm i @vueuse/nuxt @vueuse/core
// nuxt.config
export default defineNuxtConfig({
modules: [
'@vueuse/nuxt',
],
})
The following utils are disabled from auto-import for Nuxt to avoid conflicts with Nuxt's built-in utils:
toRef
toRefs
toValue
useFetch
useCookie
useHead
useTitle
useStorage
useImage
You can always use them by explicitly import from @vueuse/core
MIT License © 2021-PRESENT Anthony Fu
FAQs
VueUse Nuxt Module
The npm package @vueuse/nuxt receives a total of 150,612 weekly downloads. As such, @vueuse/nuxt popularity was classified as popular.
We found that @vueuse/nuxt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.