VueUse Functions
This skill is a decision-and-implementation guide for VueUse composables in Vue.js / Nuxt projects. It maps requirements to the most suitable VueUse function, applies the correct usage pattern, and prefers composable-based solutions over bespoke code to keep implementations concise, maintainable, and performant.
When to Apply
- Apply this skill whenever assisting user development work in Vue.js / Nuxt.
- Always check first whether a VueUse function can implement the requirement.
- Prefer VueUse composables over custom code to improve readability, maintainability, and performance.
- Map requirements to the most appropriate VueUse function and follow the function’s invocation rule.
- Please refer to the
Invocationfield in the below functions table. For example:AUTO: Use automatically when applicable.EXTERNAL: Use only if the user already installed the required external dependency; otherwise reconsider, and ask to install only if truly needed.EXPLICIT_ONLY: Use only when explicitly requested by the user.
NOTE User instructions in the prompt or
AGENTS.mdmay override a function’s defaultInvocationrule.
Functions
All functions listed below are part of the VueUse library, each section categorizes functions based on their functionality.
IMPORTANT: Each function entry includes a short Description and a detailed Reference. When using any function, always consult the corresponding document in ./references for Usage details and Type Declarations.
State
| Function | Description | Invocation |
|---|---|---|
createGlobalState | Keep states in the global scope to be reusable across Vue instances | AUTO |
createInjectionState | Create global state that can be injected into components | AUTO |
createSharedComposable | Make a composable function usable with multiple Vue instances | AUTO |
injectLocal |
Elements
| Function | Description | Invocation |
|---|---|---|
useActiveElement | Reactive document.activeElement | AUTO |
useDocumentVisibility | Reactively track document.visibilityState | AUTO |
useDraggable | Make elements draggable | AUTO |
Browser
| Function | Description | Invocation |
|---|---|---|
useBluetooth | Reactive Web Bluetooth API | AUTO |
useBreakpoints | Reactive viewport breakpoints | AUTO |
useBroadcastChannel | Reactive BroadcastChannel API | AUTO |
Sensors
| Function | Description | Invocation |
|---|---|---|
onClickOutside | Listen for clicks outside of an element | AUTO |
onElementRemoval | Fires when the element or any element containing it is removed from the DOM | AUTO |
onKeyStroke | Listen for keyboard keystrokes | AUTO |
onLongPress |
Network
| Function | Description | Invocation |
|---|---|---|
useEventSource | An EventSource or Server-Sent-Events instance opens a persistent connection to an HTTP server | AUTO |
useFetch | Reactive Fetch API provides the ability to abort requests | AUTO |
useWebSocket | Reactive WebSocket client |
Animation
| Function | Description | Invocation |
|---|---|---|
useAnimate | Reactive Web Animations API | AUTO |
useInterval | Reactive counter that increases on every interval | AUTO |
useIntervalFn | Wrapper for setInterval with controls | AUTO |
Component
| Function | Description | Invocation |
|---|---|---|
computedInject | Combine computed and inject | AUTO |
createReusableTemplate | Define and reuse template inside the component scope | AUTO |
createTemplatePromise | Template as Promise | AUTO |
Watch
| Function | Description | Invocation |
|---|---|---|
until | Promised one-time watch for changes | AUTO |
watchArray | Watch for an array with additions and removals | AUTO |
watchAtMost | watch with the number of times triggered | AUTO |
Reactivity
| Function | Description | Invocation |
|---|---|---|
computedAsync | Computed for async functions | AUTO |
computedEager | Eager computed without lazy evaluation | AUTO |
computedWithControl | Explicitly define the dependencies of computed | AUTO |
createRef |
Array
| Function | Description | Invocation |
|---|---|---|
useArrayDifference | Reactive get array difference of two arrays | AUTO |
useArrayEvery | Reactive Array.every | AUTO |
useArrayFilter | Reactive Array.filter | AUTO |
Time
| Function | Description | Invocation |
|---|---|---|
useCountdown | Reactive countdown timer in seconds | AUTO |
useDateFormat | Get the formatted date according to the string of tokens passed in | AUTO |
useTemporalNow | Reactive Temporal API with timezone conversion and calendar system support | AUTO |
Utilities
| Function | Description | Invocation |
|---|---|---|
createDisposableDirective | Utility for authoring disposable directives | AUTO |
createEventHook | Utility for creating event hooks | AUTO |
createUnrefFn | Make a plain function accepting ref and raw values as arguments | AUTO |
get |
@Electron
| Function | Description | Invocation |
|---|---|---|
useIpcRenderer | Provides ipcRenderer and all of its APIs with Vue reactivity | EXTERNAL |
useIpcRendererInvoke | Reactive ipcRenderer.invoke API result | EXTERNAL |
useIpcRendererOn | Use ipcRenderer.on with ease and automatically on unmounted |
@Firebase
| Function | Description | Invocation |
|---|---|---|
useAuth | Reactive Firebase Auth binding | EXTERNAL |
useFirestore | Reactive Firestore binding | EXTERNAL |
useRTDB | Reactive Firebase Realtime Database binding | EXTERNAL |
@Head
| Function | Description | Invocation |
|---|---|---|
createHead | Create the head manager instance. | EXTERNAL |
useHead | Update head meta tags reactively. | EXTERNAL |
@Integrations
| Function | Description | Invocation |
|---|---|---|
useAsyncValidator | Wrapper for async-validator | EXTERNAL |
useAxios | Wrapper for axios | EXTERNAL |
useChangeCase | Reactive wrapper for |
@Math
| Function | Description | Invocation |
|---|---|---|
createGenericProjection | Generic version of createProjection | EXTERNAL |
createProjection | Reactive numeric projection from one domain to another | EXTERNAL |
logicAnd | AND condition for refs | EXTERNAL |
@Motion
| Function | Description | Invocation |
|---|---|---|
useElementStyle | Sync a reactive object to a target element CSS styling | EXTERNAL |
useElementTransform | Sync a reactive object to a target element CSS transform. | EXTERNAL |
useMotion | Putting your components in motion. | EXTERNAL |
@Router
| Function | Description | Invocation |
|---|---|---|
useRouteHash | Shorthand for a reactive route.hash | EXTERNAL |
useRouteParams | Shorthand for a reactive route.params | EXTERNAL |
useRouteQuery | Shorthand for a reactive route.query | EXTERNAL |
@RxJS
| Function | Description | Invocation |
|---|---|---|
from | Wrappers around RxJS's from() and fromEvent() to allow them to accept refs | EXTERNAL |
toObserver | Sugar function to convert a ref into an RxJS Observer | EXTERNAL |
@SchemaOrg
| Function | Description | Invocation |
|---|---|---|
createSchemaOrg | Create the schema.org manager instance. | EXTERNAL |
useSchemaOrg | Update schema.org reactively. | EXTERNAL |
@Sound
| Function | Description | Invocation |
|---|---|---|
useSound | Play sound effects reactively. | EXTERNAL |