vueuse-functions

Original🇺🇸 English
Not Translated

Apply VueUse composables where appropriate to build concise, maintainable Vue.js / Nuxt features.

2installs
Added on

NPX Install

npx skill4agent add vueuse/vueuse vueuse-functions

SKILL.md Content

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
    Invocation
    field 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.md
      may override a function’s default
      Invocation
      rule.

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

FunctionDescriptionInvocation
createGlobalState
Keep states in the global scope to be reusable across Vue instancesAUTO
createInjectionState
Create global state that can be injected into componentsAUTO
createSharedComposable
Make a composable function usable with multiple Vue instancesAUTO
injectLocal
Extended
inject
with ability to call
provideLocal
to provide the value in the same component
AUTO
provideLocal
Extended
provide
with ability to call
injectLocal
to obtain the value in the same component
AUTO
useAsyncState
Reactive async stateAUTO
useDebouncedRefHistory
Shorthand for
useRefHistory
with debounced filter
AUTO
useLastChanged
Records the timestamp of the last changeAUTO
useLocalStorage
Reactive LocalStorageAUTO
useManualRefHistory
Manually track the change history of a ref when the using calls
commit()
AUTO
useRefHistory
Track the change history of a refAUTO
useSessionStorage
Reactive SessionStorageAUTO
useStorage
Create a reactive ref that can be used to access & modify LocalStorage or SessionStorageAUTO
useStorageAsync
Reactive Storage in with async supportAUTO
useThrottledRefHistory
Shorthand for
useRefHistory
with throttled filter
AUTO

Elements

FunctionDescriptionInvocation
useActiveElement
Reactive
document.activeElement
AUTO
useDocumentVisibility
Reactively track
document.visibilityState
AUTO
useDraggable
Make elements draggableAUTO
useDropZone
Create a zone where files can be droppedAUTO
useElementBounding
Reactive bounding box of an HTML elementAUTO
useElementSize
Reactive size of an HTML elementAUTO
useElementVisibility
Tracks the visibility of an element within the viewportAUTO
useIntersectionObserver
Detects that a target element's visibilityAUTO
useMouseInElement
Reactive mouse position related to an elementAUTO
useMutationObserver
Watch for changes being made to the DOM treeAUTO
useParentElement
Get parent element of the given elementAUTO
useResizeObserver
Reports changes to the dimensions of an Element's content or the border-boxAUTO
useWindowFocus
Reactively track window focus with
window.onfocus
and
window.onblur
events
AUTO
useWindowScroll
Reactive window scrollAUTO
useWindowSize
Reactive window sizeAUTO

Browser

FunctionDescriptionInvocation
useBluetooth
Reactive Web Bluetooth APIAUTO
useBreakpoints
Reactive viewport breakpointsAUTO
useBroadcastChannel
Reactive BroadcastChannel APIAUTO
useBrowserLocation
Reactive browser locationAUTO
useClipboard
Reactive Clipboard APIAUTO
useClipboardItems
Reactive Clipboard APIAUTO
useColorMode
Reactive color mode (dark / light / customs) with auto data persistenceAUTO
useCssSupports
SSR compatible and reactive
CSS.supports
AUTO
useCssVar
Manipulate CSS variablesAUTO
useDark
Reactive dark mode with auto data persistenceAUTO
useEventListener
Use EventListener with easeAUTO
useEyeDropper
Reactive EyeDropper APIAUTO
useFavicon
Reactive faviconAUTO
useFileDialog
Open file dialog with easeAUTO
useFileSystemAccess
Create and read and write local files with FileSystemAccessAPIAUTO
useFullscreen
Reactive Fullscreen APIAUTO
useGamepad
Provides reactive bindings for the Gamepad APIAUTO
useImage
Reactive load an image in the browserAUTO
useMediaControls
Reactive media controls for both
audio
and
video
elements
AUTO
useMediaQuery
Reactive Media QueryAUTO
useMemory
Reactive Memory InfoAUTO
useObjectUrl
Reactive URL representing an objectAUTO
usePerformanceObserver
Observe performance metricsAUTO
usePermission
Reactive Permissions APIAUTO
usePreferredColorScheme
Reactive prefers-color-scheme media queryAUTO
usePreferredContrast
Reactive prefers-contrast media queryAUTO
usePreferredDark
Reactive dark theme preferenceAUTO
usePreferredLanguages
Reactive Navigator LanguagesAUTO
usePreferredReducedMotion
Reactive prefers-reduced-motion media queryAUTO
usePreferredReducedTransparency
Reactive prefers-reduced-transparency media queryAUTO
useScreenOrientation
Reactive Screen Orientation APIAUTO
useScreenSafeArea
Reactive
env(safe-area-inset-*)
AUTO
useScriptTag
Creates a script tagAUTO
useShare
Reactive Web Share APIAUTO
useSSRWidth
Used to set a global viewport width which will be used when rendering SSR components that rely on the viewport width like
useMediaQuery
or
useBreakpoints
AUTO
useStyleTag
Inject reactive
style
element in head
AUTO
useTextareaAutosize
Automatically update the height of a textarea depending on the contentAUTO
useTextDirection
Reactive dir of the element's textAUTO
useTitle
Reactive document titleAUTO
useUrlSearchParams
Reactive URLSearchParamsAUTO
useVibrate
Reactive Vibration APIAUTO
useWakeLock
Reactive Screen Wake Lock APIAUTO
useWebNotification
Reactive NotificationAUTO
useWebWorker
Simple Web Workers registration and communicationAUTO
useWebWorkerFn
Run expensive functions without blocking the UIAUTO

Sensors

FunctionDescriptionInvocation
onClickOutside
Listen for clicks outside of an elementAUTO
onElementRemoval
Fires when the element or any element containing it is removed from the DOMAUTO
onKeyStroke
Listen for keyboard keystrokesAUTO
onLongPress
Listen for a long press on an elementAUTO
onStartTyping
Fires when users start typing on non-editable elementsAUTO
useBattery
Reactive Battery Status APIAUTO
useDeviceMotion
Reactive DeviceMotionEventAUTO
useDeviceOrientation
Reactive DeviceOrientationEventAUTO
useDevicePixelRatio
Reactively track
window.devicePixelRatio
AUTO
useDevicesList
Reactive enumerateDevices listing available input/output devicesAUTO
useDisplayMedia
Reactive
mediaDevices.getDisplayMedia
streaming
AUTO
useElementByPoint
Reactive element by pointAUTO
useElementHover
Reactive element's hover stateAUTO
useFocus
Reactive utility to track or set the focus state of a DOM elementAUTO
useFocusWithin
Reactive utility to track if an element or one of its decendants has focusAUTO
useFps
Reactive FPS (frames per second)AUTO
useGeolocation
Reactive Geolocation APIAUTO
useIdle
Tracks whether the user is being inactiveAUTO
useInfiniteScroll
Infinite scrolling of the elementAUTO
useKeyModifier
Reactive Modifier StateAUTO
useMagicKeys
Reactive keys pressed stateAUTO
useMouse
Reactive mouse positionAUTO
useMousePressed
Reactive mouse pressing stateAUTO
useNavigatorLanguage
Reactive navigator.languageAUTO
useNetwork
Reactive Network statusAUTO
useOnline
Reactive online stateAUTO
usePageLeave
Reactive state to show whether the mouse leaves the pageAUTO
useParallax
Create parallax effect easilyAUTO
usePointer
Reactive pointer stateAUTO
usePointerLock
Reactive pointer lockAUTO
usePointerSwipe
Reactive swipe detection based on PointerEventsAUTO
useScroll
Reactive scroll position and stateAUTO
useScrollLock
Lock scrolling of the elementAUTO
useSpeechRecognition
Reactive SpeechRecognitionAUTO
useSpeechSynthesis
Reactive SpeechSynthesisAUTO
useSwipe
Reactive swipe detection based on
TouchEvents
AUTO
useTextSelection
Reactively track user text selection based on
Window.getSelection
AUTO
useUserMedia
Reactive
mediaDevices.getUserMedia
streaming
AUTO

Network

FunctionDescriptionInvocation
useEventSource
An EventSource or Server-Sent-Events instance opens a persistent connection to an HTTP serverAUTO
useFetch
Reactive Fetch API provides the ability to abort requestsAUTO
useWebSocket
Reactive WebSocket clientAUTO

Animation

FunctionDescriptionInvocation
useAnimate
Reactive Web Animations APIAUTO
useInterval
Reactive counter that increases on every intervalAUTO
useIntervalFn
Wrapper for
setInterval
with controls
AUTO
useNow
Reactive current Date instanceAUTO
useRafFn
Call function on every
requestAnimationFrame
AUTO
useTimeout
Reactive value that becomes
true
after a given time
AUTO
useTimeoutFn
Wrapper for
setTimeout
with controls
AUTO
useTimestamp
Reactive current timestampAUTO
useTransition
Transition between valuesAUTO

Component

FunctionDescriptionInvocation
computedInject
Combine
computed
and
inject
AUTO
createReusableTemplate
Define and reuse template inside the component scopeAUTO
createTemplatePromise
Template as PromiseAUTO
templateRef
Shorthand for binding ref to template elementAUTO
tryOnBeforeMount
Safe
onBeforeMount
AUTO
tryOnBeforeUnmount
Safe
onBeforeUnmount
AUTO
tryOnMounted
Safe
onMounted
AUTO
tryOnScopeDispose
Safe
onScopeDispose
AUTO
tryOnUnmounted
Safe
onUnmounted
AUTO
unrefElement
Retrieves the underlying DOM element from a Vue ref or component instanceAUTO
useCurrentElement
Get the DOM element of current component as a refAUTO
useMounted
Mounted state in refAUTO
useTemplateRefsList
Shorthand for binding refs to template elements and components inside
v-for
AUTO
useVirtualList
Create virtual lists with easeAUTO
useVModel
Shorthand for v-model bindingAUTO
useVModels
Shorthand for props v-model bindingAUTO

Watch

FunctionDescriptionInvocation
until
Promised one-time watch for changesAUTO
watchArray
Watch for an array with additions and removalsAUTO
watchAtMost
watch
with the number of times triggered
AUTO
watchDebounced
Debounced watchAUTO
watchDeep
Shorthand for watching value with
{deep: true}
AUTO
watchIgnorable
Ignorable watchAUTO
watchImmediate
Shorthand for watching value with
{immediate: true}
AUTO
watchOnce
Shorthand for watching value with
{ once: true }
AUTO
watchPausable
Pausable watchAUTO
watchThrottled
Throttled watchAUTO
watchTriggerable
Watch that can be triggered manuallyAUTO
watchWithFilter
watch
with additional EventFilter control
AUTO
whenever
Shorthand for watching value to be truthyAUTO

Reactivity

FunctionDescriptionInvocation
computedAsync
Computed for async functionsAUTO
computedEager
Eager computed without lazy evaluationAUTO
computedWithControl
Explicitly define the dependencies of computedAUTO
createRef
Returns a
deepRef
or
shallowRef
depending on the
deep
param
AUTO
extendRef
Add extra attributes to RefAUTO
reactify
Converts plain functions into reactive functionsAUTO
reactifyObject
Apply
reactify
to an object
AUTO
reactiveComputed
Computed reactive objectAUTO
reactiveOmit
Reactively omit fields from a reactive objectAUTO
reactivePick
Reactively pick fields from a reactive objectAUTO
refAutoReset
A ref which will be reset to the default value after some timeAUTO
refDebounced
Debounce execution of a ref valueAUTO
refDefault
Apply default value to a refAUTO
refManualReset
Create a ref with manual reset functionalityAUTO
refThrottled
Throttle changing of a ref valueAUTO
refWithControl
Fine-grained controls over ref and its reactivityAUTO
syncRef
Two-way refs synchronizationAUTO
syncRefs
Keep target refs in sync with a source refAUTO
toReactive
Converts ref to reactiveAUTO
toRef
Normalize value/ref/getter to
ref
or
computed
EXPLICIT_ONLY
toRefs
Extended
toRefs
that also accepts refs of an object
AUTO

Array

FunctionDescriptionInvocation
useArrayDifference
Reactive get array difference of two arraysAUTO
useArrayEvery
Reactive
Array.every
AUTO
useArrayFilter
Reactive
Array.filter
AUTO
useArrayFind
Reactive
Array.find
AUTO
useArrayFindIndex
Reactive
Array.findIndex
AUTO
useArrayFindLast
Reactive
Array.findLast
AUTO
useArrayIncludes
Reactive
Array.includes
AUTO
useArrayJoin
Reactive
Array.join
AUTO
useArrayMap
Reactive
Array.map
AUTO
useArrayReduce
Reactive
Array.reduce
AUTO
useArraySome
Reactive
Array.some
AUTO
useArrayUnique
Reactive unique arrayAUTO
useSorted
Reactive sort arrayAUTO

Time

FunctionDescriptionInvocation
useCountdown
Reactive countdown timer in secondsAUTO
useDateFormat
Get the formatted date according to the string of tokens passed inAUTO
useTimeAgo
Reactive time agoAUTO
useTimeAgoIntl
Reactive time ago with i18n supportedAUTO

Utilities

FunctionDescriptionInvocation
createEventHook
Utility for creating event hooksAUTO
createUnrefFn
Make a plain function accepting ref and raw values as argumentsAUTO
get
Shorthand for accessing
ref.value
EXPLICIT_ONLY
isDefined
Non-nullish checking type guard for RefAUTO
makeDestructurable
Make isomorphic destructurable for object and array at the same timeAUTO
set
Shorthand for
ref.value = x
EXPLICIT_ONLY
useAsyncQueue
Executes each asynchronous task sequentially and passes the current task result to the next taskAUTO
useBase64
Reactive base64 transformingAUTO
useCached
Cache a ref with a custom comparatorAUTO
useCloned
Reactive clone of a refAUTO
useConfirmDialog
Creates event hooks to support modals and confirmation dialog chainsAUTO
useCounter
Basic counter with utility functionsAUTO
useCycleList
Cycle through a list of itemsAUTO
useDebounceFn
Debounce execution of a functionAUTO
useEventBus
A basic event busAUTO
useMemoize
Cache results of functions depending on arguments and keep it reactiveAUTO
useOffsetPagination
Reactive offset paginationAUTO
usePrevious
Holds the previous value of a refAUTO
useStepper
Provides helpers for building a multi-step wizard interfaceAUTO
useSupported
SSR compatibility
isSupported
AUTO
useThrottleFn
Throttle execution of a functionAUTO
useTimeoutPoll
Use timeout to poll somethingAUTO
useToggle
A boolean switcher with utility functionsAUTO
useToNumber
Reactively convert a string ref to numberAUTO
useToString
Reactively convert a ref to stringAUTO

@Electron

FunctionDescriptionInvocation
useIpcRenderer
Provides ipcRenderer and all of its APIs with Vue reactivityEXTERNAL
useIpcRendererInvoke
Reactive ipcRenderer.invoke API resultEXTERNAL
useIpcRendererOn
Use ipcRenderer.on with ease and ipcRenderer.removeListener automatically on unmountedEXTERNAL
useZoomFactor
Reactive WebFrame zoom factorEXTERNAL
useZoomLevel
Reactive WebFrame zoom levelEXTERNAL

@Firebase

FunctionDescriptionInvocation
useAuth
Reactive Firebase Auth bindingEXTERNAL
useFirestore
Reactive Firestore bindingEXTERNAL
useRTDB
Reactive Firebase Realtime Database bindingEXTERNAL

@Head

FunctionDescriptionInvocation
createHead
Create the head manager instance.EXTERNAL
useHead
Update head meta tags reactively.EXTERNAL

@Integrations

FunctionDescriptionInvocation
useAsyncValidator
Wrapper for
async-validator
EXTERNAL
useAxios
Wrapper for
axios
EXTERNAL
useChangeCase
Reactive wrapper for
change-case
EXTERNAL
useCookies
Wrapper for
universal-cookie
EXTERNAL
useDrauu
Reactive instance for drauuEXTERNAL
useFocusTrap
Reactive wrapper for
focus-trap
EXTERNAL
useFuse
Easily implement fuzzy search using a composable with Fuse.jsEXTERNAL
useIDBKeyval
Wrapper for
idb-keyval
EXTERNAL
useJwt
Wrapper for
jwt-decode
EXTERNAL
useNProgress
Reactive wrapper for
nprogress
EXTERNAL
useQRCode
Wrapper for
qrcode
EXTERNAL
useSortable
Wrapper for
sortable
EXTERNAL

@Math

FunctionDescriptionInvocation
createGenericProjection
Generic version of
createProjection
EXTERNAL
createProjection
Reactive numeric projection from one domain to anotherEXTERNAL
logicAnd
AND
condition for refs
EXTERNAL
logicNot
NOT
condition for ref
EXTERNAL
logicOr
OR
conditions for refs
EXTERNAL
useAbs
Reactive
Math.abs
EXTERNAL
useAverage
Get the average of an array reactivelyEXTERNAL
useCeil
Reactive
Math.ceil
EXTERNAL
useClamp
Reactively clamp a value between two other valuesEXTERNAL
useFloor
Reactive
Math.floor
EXTERNAL
useMath
Reactive
Math
methods
EXTERNAL
useMax
Reactive
Math.max
EXTERNAL
useMin
Reactive
Math.min
EXTERNAL
usePrecision
Reactively set the precision of a numberEXTERNAL
useProjection
Reactive numeric projection from one domain to anotherEXTERNAL
useRound
Reactive
Math.round
EXTERNAL
useSum
Get the sum of an array reactivelyEXTERNAL
useTrunc
Reactive
Math.trunc
EXTERNAL

@Motion

FunctionDescriptionInvocation
useElementStyle
Sync a reactive object to a target element CSS stylingEXTERNAL
useElementTransform
Sync a reactive object to a target element CSS transform.EXTERNAL
useMotion
Putting your components in motion.EXTERNAL
useMotionProperties
Access Motion Properties for a target element.EXTERNAL
useMotionVariants
Handle the Variants state and selection.EXTERNAL
useSpring
Spring animations.EXTERNAL

@Router

FunctionDescriptionInvocation
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

FunctionDescriptionInvocation
from
Wrappers around RxJS's
from()
and
fromEvent()
to allow them to accept
ref
s
EXTERNAL
toObserver
Sugar function to convert a
ref
into an RxJS Observer
EXTERNAL
useExtractedObservable
Use an RxJS
Observable
as extracted from one or more composables
EXTERNAL
useObservable
Use an RxJS
Observable
EXTERNAL
useSubject
Bind an RxJS
Subject
to a
ref
and propagate value changes both ways
EXTERNAL
useSubscription
Use an RxJS
Subscription
without worrying about unsubscribing from it or creating memory leaks
EXTERNAL
watchExtractedObservable
Watch the values of an RxJS
Observable
as extracted from one or more composables
EXTERNAL

@SchemaOrg

FunctionDescriptionInvocation
createSchemaOrg
Create the schema.org manager instance.EXTERNAL
useSchemaOrg
Update schema.org reactively.EXTERNAL

@Sound

FunctionDescriptionInvocation
useSound
Play sound effects reactively.EXTERNAL