Back to Vue.js

vueuse

Vue.jsNuxt.jscomposablesreactive programmingutilitiesfrontend developmentbrowser APIsstate management
682🕒 2026-06-01Source ↗

Install this skill

npx skills add onmax/nuxt-skills

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

VueUse is a primary library of utility functions for Vue 3 Composition API, providing pre-written logic for common browser, state, and reactivity challenges. Instead of writing custom logic for DOM observation, local storage synchronization, or event debouncing, developers can import tested functions that handle these tasks with built-in reactivity and cleanup. It supports both standard Vue 3 setups and Nuxt projects, with the latter benefiting from automatic imports. The library abstracts complex browser APIs into simple, readable hooks that follow Vue’s reactive patterns. By standardizing these frequent implementation details, the library helps maintain consistent code structures across projects, particularly for handling side effects that would otherwise require manual lifecycle management or event listeners.

When to Use This Skill

  • Persisting user-defined theme preferences or form drafts between page reloads
  • Implementing infinite scroll or lazy loading via intersection observers
  • Handling complex input interactions like drag-and-drop or debounced search inputs
  • Synchronizing UI updates with window resizing or device orientation changes

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • How do I sync state to localStorage in Vue?
  • Show me how to use debouncing in Vue 3
  • What is the best way to track window size changes?
  • How do I use an intersection observer as a composable?
  • Help me implement a shared state singleton

Pro Tips

  • 💡Always check the comprehensive VueUse documentation first; a composable likely exists for your specific use case, saving significant development time.
  • 💡Combine multiple VueUse composables for complex scenarios, such as `useFetch` with `useIntervalFn` for efficient data polling.
  • 💡Utilize the Nuxt module for automatic composable imports, simplifying your component code and reducing boilerplate.

What this skill does

  • Synchronizes reactive state with localStorage and sessionStorage
  • Tracks browser environment interactions like mouse position, window size, and media queries
  • Provides debounced and throttled versions of standard Vue watch and ref primitives
  • Manages complex DOM observations including IntersectionObserver and ResizeObserver
  • Offers network-ready hooks for WebSocket and Fetch requests

When not to use it

  • When a project requires only one simple functionality and wants to avoid adding a dependency
  • When custom logic needs strict control over every frame of animation or performance cycle

Example workflow

  1. Install @vueuse/core via your package manager
  2. Identify the specific browser or state requirement in your component
  3. Browse the library documentation or reference file to find the matching hook
  4. Import the hook and invoke it within the setup function or script setup
  5. Bind the returned reactive variables directly to your component template

Prerequisites

  • Vue 3.5+
  • Basic understanding of the Composition API

Pitfalls & limitations

  • !Many functions access browser APIs and will throw errors if called directly in SSR during the build phase
  • !Component ref elements must be resolved correctly using unrefElement to avoid null reference errors
  • !Over-importing large utility sets can impact bundle size if not tree-shaken correctly

FAQ

Should I use VueUse inside of a Nuxt project?
Yes, using the @vueuse/nuxt module provides auto-imports for all composables, eliminating the need for manual import statements.
How do I handle SSR with browser-based hooks?
Wrap the composable call in an onMounted hook or check the isClient constant to ensure the code executes only in the browser.
Can I use VueUse with component refs?
Yes, but you must pass the ref to unrefElement to ensure the composable receives the actual DOM node rather than the component instance.

How it compares

VueUse replaces manual boilerplate code for standard Web APIs with high-quality, pre-tested, and reactive primitives, whereas manual implementation often requires redundant lifecycle management and error-prone side-effect cleanup.

Source & trust

682 stars🕒 Updated 2026-06-01
📄 Full skill instructions — original source: onmax/nuxt-skills
# VueUse

Collection of essential Vue Composition utilities. Check VueUse before writing custom composables - most patterns already implemented.

**Current stable:** VueUse 14.x for Vue 3.5+

## Installation

**Vue 3:**

pnpm add @vueuse/core


**Nuxt:**

pnpm add @vueuse/nuxt @vueuse/core


// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@vueuse/nuxt'],
})


Nuxt module auto-imports composables - no import needed.

## Categories

| Category | Examples |
| ---------- | ---------------------------------------------------------- |
| State | useLocalStorage, useSessionStorage, useRefHistory |
| Elements | useElementSize, useIntersectionObserver, useResizeObserver |
| Browser | useClipboard, useFullscreen, useMediaQuery |
| Sensors | useMouse, useKeyboard, useDeviceOrientation |
| Network | useFetch, useWebSocket, useEventSource |
| Animation | useTransition, useInterval, useTimeout |
| Component | useVModel, useVirtualList, useTemplateRefsList |
| Watch | watchDebounced, watchThrottled, watchOnce |
| Reactivity | createSharedComposable, toRef, toReactive |
| Array | useArrayFilter, useArrayMap, useSorted |
| Time | useDateFormat, useNow, useTimeAgo |
| Utilities | useDebounce, useThrottle, useMemoize |

## Quick Reference

Load composable files based on what you need:

| Working on... | Load file |
| -------------------- | ------------------------------------------------------ |
| Finding a composable | [references/composables.md](references/composables.md) |
| Specific composable | composables/<name>.md |

## Loading Files

**Start with [references/composables.md](references/composables.md)** to find the right composable.

Then load the specific composable file for detailed usage: composables/use-mouse.md, composables/use-local-storage.md, etc.

**DO NOT load all files at once** - wastes context on irrelevant patterns.

## Common Patterns

**State persistence:**

const state = useLocalStorage('my-key', { count: 0 })


**Mouse tracking:**

const { x, y } = useMouse()


**Debounced ref:**

const search = ref('')
const debouncedSearch = refDebounced(search, 300)


**Shared composable (singleton):**

const useSharedMouse = createSharedComposable(useMouse)


## SSR Gotchas

Many VueUse composables use browser APIs unavailable during SSR.

**Check with isClient:**

import { isClient } from '@vueuse/core'

if (isClient) {
// Browser-only code
const { width } = useWindowSize()
}


**Wrap in onMounted:**

const width = ref(0)

onMounted(() => {
// Only runs in browser
const { width: w } = useWindowSize()
width.value = w.value
})


**Use SSR-safe composables:**

// These check isClient internally
const mouse = useMouse() // Returns {x: 0, y: 0} on server
const storage = useLocalStorage('key', 'default') // Uses default on server


**@vueuse/nuxt auto-handles SSR** - composables return safe defaults on server.

## Target Element Refs

When targeting component refs instead of DOM elements:

import type { MaybeElementRef } from '@vueuse/core'

// Component ref needs .$el to get DOM element
const compRef = ref<ComponentInstance>()
const { width } = useElementSize(compRef) // ❌ Won't work

// Use MaybeElementRef pattern
import { unrefElement } from '@vueuse/core'

const el = computed(() => unrefElement(compRef)) // Gets .$el
const { width } = useElementSize(el) // ✅ Works


**Or access $el directly:**

const compRef = ref<ComponentInstance>()

onMounted(() => {
const el = compRef.value?.$el as HTMLElement
const { width } = useElementSize(el)
})

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/vueuse/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/onmax/nuxt-skills/vueuse/SKILL.md
  • Cursor: ~/.cursor/skills/onmax/nuxt-skills/vueuse/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/onmax/nuxt-skills/vueuse/SKILL.md

🚀 Install with CLI:
npx skills add onmax/nuxt-skills

Read the Master Guide: Mastering Agent Skills

Recommended Rules

View more rules

Recommended Workflows

View more workflows

Recommended MCP Servers

View more MCP servers

Take It Further

Maximize your productivity with these powerful resources

📋

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
📖

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid vue.js issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under Vue.js and is published by Onmax, maintained in onmax/nuxt-skills.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.