vueuse
Use when working with VueUse composables - provides reactive utilities for state, browser APIs, sensors, network, animations. Check VueUse before writing custom composables - most patterns already implemented.
- License 许可
- MIT
- 最近更新
- 2026-08-29
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- vueuse
- license
- MIT
- metadata
- { "role": "specialist", "scope": "implementation", "domain": "frontend", "version": "1.0.0", "triggers": "VueUse, useStorage, useFetch, useEventListener, composable, @vueuse/core, reactive utility", "output-format": "code", "related-skills": "vue-best-practices, vue-pinia-best-practices" }
- description
- Use when working with VueUse composables - provides reactive utilities for state, browser APIs, sensors, network, animations. Check VueUse before writing custom composables - most patterns already implemented.
02 资源文件 267
- 参考文档composables/computed-async.md423 B
- 参考文档composables/computed-eager.md453 B
- 参考文档composables/computed-inject.md536 B
- 参考文档composables/computed-with-control.md406 B
- 参考文档composables/create-event-hook.md681 B
- 参考文档composables/create-generic-projection.md248 B
- 参考文档composables/create-global-state.md448 B
- 参考文档composables/create-injection-state.md762 B
- 参考文档composables/create-projection.md497 B
- 参考文档composables/create-ref.md444 B
- 参考文档composables/create-reusable-template.md638 B
- 参考文档composables/create-shared-composable.md534 B
- 参考文档composables/create-template-promise.md709 B
- 参考文档composables/create-unref-fn.md733 B
- 参考文档composables/extend-ref.md625 B
- 参考文档composables/from.md173 B
- 参考文档composables/get.md247 B
- 参考文档composables/inject-local.md420 B
- 参考文档composables/is-defined.md373 B
- 参考文档composables/logic-and.md373 B
- 参考文档composables/logic-not.md335 B
- 参考文档composables/logic-or.md366 B
- 参考文档composables/make-destructurable.md330 B
- 参考文档composables/on-click-outside.md1.1 KB
- 参考文档composables/on-element-removal.md394 B
- 参考文档composables/on-key-stroke.md534 B
- 参考文档composables/on-long-press.md1.3 KB
- 参考文档composables/on-start-typing.md631 B
- 参考文档composables/provide-local.md421 B
- 参考文档composables/reactify-object.md529 B
- 参考文档composables/reactify.md932 B
- 参考文档composables/reactive-computed.md418 B
- 参考文档composables/reactive-omit.md411 B
- 参考文档composables/reactive-pick.md411 B
- 参考文档composables/ref-auto-reset.md494 B
- 参考文档composables/ref-debounced.md595 B
- 参考文档composables/ref-default.md427 B
- 参考文档composables/ref-manual-reset.md409 B
- 参考文档composables/ref-throttled.md346 B
- 参考文档composables/ref-with-control.md846 B
- 参考文档composables/set.md247 B
- 参考文档composables/sync-ref.md406 B
- 参考文档composables/sync-refs.md656 B
- 参考文档composables/template-ref.md428 B
- 参考文档composables/to-observer.md242 B
- 参考文档composables/to-reactive.md671 B
- 参考文档composables/to-ref.md364 B
- 参考文档composables/to-refs.md725 B
- 参考文档composables/try-on-before-mount.md327 B
- 参考文档composables/try-on-before-unmount.md323 B
- 参考文档composables/try-on-mounted.md311 B
- 参考文档composables/try-on-scope-dispose.md323 B
- 参考文档composables/try-on-unmounted.md307 B
- 参考文档composables/unref-element.md747 B
- 参考文档composables/until.md459 B
- 参考文档composables/use-abs.md259 B
- 参考文档composables/use-active-element.md710 B
- 参考文档composables/use-animate.md1.6 KB
- 参考文档composables/use-array-difference.md607 B
- 参考文档composables/use-array-every.md481 B
- 参考文档composables/use-array-filter.md503 B
- 参考文档composables/use-array-find-index.md490 B
- 参考文档composables/use-array-find-last.md340 B
- 参考文档composables/use-array-find.md324 B
- 参考文档composables/use-array-includes.md403 B
- 参考文档composables/use-array-join.md458 B
- 参考文档composables/use-array-map.md492 B
- 参考文档composables/use-array-reduce.md312 B
- 参考文档composables/use-array-some.md473 B
- 参考文档composables/use-array-unique.md492 B
- 参考文档composables/use-async-queue.md1.2 KB
- 参考文档composables/use-async-state.md896 B
- 参考文档composables/use-async-validator.md649 B
- 参考文档composables/use-auth.md963 B
- 参考文档composables/use-average.md311 B
- 参考文档composables/use-axios.md926 B
- 参考文档composables/use-base64.md664 B
- 参考文档composables/use-battery.md888 B
- 参考文档composables/use-bluetooth.md972 B
- 参考文档composables/use-breakpoints.md811 B
- 参考文档composables/use-broadcast-channel.md1006 B
- 参考文档composables/use-browser-location.md283 B
- 参考文档composables/use-cached.md636 B
- 参考文档composables/use-ceil.md254 B
- 参考文档composables/use-change-case.md685 B
- 参考文档composables/use-clamp.md329 B
- 参考文档composables/use-clipboard-items.md1.6 KB
- 参考文档composables/use-clipboard.md1.5 KB
- 参考文档composables/use-cloned.md742 B
- 参考文档composables/use-color-mode.md1.4 KB
- 参考文档composables/use-confirm-dialog.md981 B
- 参考文档composables/use-cookies.md625 B
- 参考文档composables/use-countdown.md1023 B
- 参考文档composables/use-counter.md440 B
- 参考文档composables/use-css-supports.md377 B
- 参考文档composables/use-css-var.md700 B
- 参考文档composables/use-current-element.md324 B
- 参考文档composables/use-cycle-list.md982 B
- 参考文档composables/use-dark.md743 B
- 参考文档composables/use-date-format.md831 B
- 参考文档composables/use-debounce-fn.md378 B
- 参考文档composables/use-debounced-ref-history.md425 B
- 参考文档composables/use-device-motion.md939 B
- 参考文档composables/use-device-orientation.md598 B
- 参考文档composables/use-device-pixel-ratio.md374 B
- 参考文档composables/use-devices-list.md829 B
- 参考文档composables/use-display-media.md1.1 KB
- 参考文档composables/use-document-visibility.md324 B
- 参考文档composables/use-draggable.md1.7 KB
- 参考文档composables/use-drauu.md938 B
- 参考文档composables/use-drop-zone.md1.5 KB
- 参考文档composables/use-element-bounding.md1.1 KB
- 参考文档composables/use-element-by-point.md633 B
- 参考文档composables/use-element-hover.md524 B
- 参考文档composables/use-element-size.md619 B
- 参考文档composables/use-element-visibility.md904 B
- 参考文档composables/use-event-bus.md679 B
- 参考文档composables/use-event-listener.md418 B
- 参考文档composables/use-event-source.md1.1 KB
- 参考文档composables/use-extracted-observable.md292 B
- 参考文档composables/use-eye-dropper.md535 B
- 参考文档composables/use-favicon.md332 B
- 参考文档composables/use-fetch.md1.6 KB
- 参考文档composables/use-file-dialog.md1.5 KB
- 参考文档composables/use-file-system-access.md835 B
- 参考文档composables/use-firestore.md467 B
- 参考文档composables/use-floor.md262 B
- 参考文档composables/use-focus-trap.md1.0 KB
- 参考文档composables/use-focus-within.md1.0 KB
- 参考文档composables/use-focus.md1.0 KB
- 参考文档composables/use-fps.md384 B
- 参考文档composables/use-fullscreen.md1003 B
- 参考文档composables/use-fuse.md715 B
- 参考文档composables/use-gamepad.md730 B
- 参考文档composables/use-geolocation.md720 B
- 参考文档composables/use-idbkeyval.md854 B
- 参考文档composables/use-idle.md843 B
- 参考文档composables/use-image.md1.2 KB
- 参考文档composables/use-infinite-scroll.md1.5 KB
- 参考文档composables/use-intersection-observer.md1.3 KB
- 参考文档composables/use-interval-fn.md675 B
- 参考文档composables/use-interval.md701 B
- 参考文档composables/use-ipc-renderer-invoke.md644 B
- 参考文档composables/use-ipc-renderer-on.md579 B
- 参考文档composables/use-ipc-renderer.md1.0 KB
- 参考文档composables/use-jwt.md810 B
- 参考文档composables/use-key-modifier.md397 B
- 参考文档composables/use-last-changed.md414 B
- 参考文档composables/use-local-storage.md162 B
- 参考文档composables/use-magic-keys.md783 B
- 参考文档composables/use-manual-ref-history.md1.2 KB
- 参考文档composables/use-math.md429 B
- 参考文档composables/use-max.md262 B
- 参考文档composables/use-media-controls.md1.6 KB
- 参考文档composables/use-media-query.md488 B
- 参考文档composables/use-memoize.md850 B
- 参考文档composables/use-memory.md650 B
- 参考文档composables/use-min.md262 B
- 参考文档composables/use-mounted.md250 B
- 参考文档composables/use-mouse-in-element.md842 B
- 参考文档composables/use-mouse-pressed.md1.2 KB
- 参考文档composables/use-mouse.md1.0 KB
- 参考文档composables/use-mutation-observer.md750 B
- 参考文档composables/use-navigator-language.md491 B
- 参考文档composables/use-network.md1.2 KB
- 参考文档composables/use-now.md641 B
- 参考文档composables/use-nprogress.md321 B
- 参考文档composables/use-object-url.md535 B
- 参考文档composables/use-observable.md420 B
- 参考文档composables/use-offset-pagination.md1.4 KB
- 参考文档composables/use-online.md257 B
- 参考文档composables/use-page-leave.md289 B
- 参考文档composables/use-parallax.md564 B
- 参考文档composables/use-parent-element.md377 B
- 参考文档composables/use-performance-observer.md517 B
- 参考文档composables/use-permission.md729 B
- 参考文档composables/use-pointer-lock.md533 B
- 参考文档composables/use-pointer-swipe.md1.2 KB
- 参考文档composables/use-pointer.md697 B
- 参考文档composables/use-precision.md620 B
- 参考文档composables/use-preferred-color-scheme.md326 B
- 参考文档composables/use-preferred-contrast.md313 B
- 参考文档composables/use-preferred-dark.md279 B
- 参考文档composables/use-preferred-languages.md538 B
- 参考文档composables/use-preferred-reduced-motion.md337 B
- 参考文档composables/use-preferred-reduced-transparency.md373 B
- 参考文档composables/use-previous.md447 B
- 参考文档composables/use-projection.md426 B
- 参考文档composables/use-qrcode.md321 B
- 参考文档composables/use-raf-fn.md927 B
- 参考文档composables/use-ref-history.md1.2 KB
- 参考文档composables/use-resize-observer.md747 B
- 参考文档composables/use-round.md262 B
- 参考文档composables/use-route-hash.md367 B
- 参考文档composables/use-route-params.md566 B
- 参考文档composables/use-route-query.md618 B
- 参考文档composables/use-rtdb.md563 B
- 参考文档composables/use-screen-orientation.md684 B
- 参考文档composables/use-screen-safe-area.md451 B
- 参考文档composables/use-script-tag.md1.1 KB
- 参考文档composables/use-scroll-lock.md481 B
- 参考文档composables/use-scroll.md907 B
- 参考文档composables/use-session-storage.md168 B
- 参考文档composables/use-share.md535 B
- 参考文档composables/use-sortable.md905 B
- 参考文档composables/use-sorted.md919 B
- 参考文档composables/use-speech-recognition.md1.2 KB
- 参考文档composables/use-speech-synthesis.md1.5 KB
- 参考文档composables/use-ssrwidth.md381 B
- 参考文档composables/use-stepper.md1.0 KB
- 参考文档composables/use-storage-async.md805 B
- 参考文档composables/use-storage.md1.5 KB
- 参考文档composables/use-style-tag.md970 B
- 参考文档composables/use-subject.md188 B
- 参考文档composables/use-subscription.md224 B
- 参考文档composables/use-sum.md287 B
- 参考文档composables/use-supported.md369 B
- 参考文档composables/use-swipe.md1.1 KB
- 参考文档composables/use-template-refs-list.md530 B
- 参考文档composables/use-text-direction.md645 B
- 参考文档composables/use-text-selection.md560 B
- 参考文档composables/use-textarea-autosize.md1.0 KB
- 参考文档composables/use-throttle-fn.md497 B
- 参考文档composables/use-throttled-ref-history.md425 B
- 参考文档composables/use-time-ago-intl.md739 B
- 参考文档composables/use-time-ago.md621 B
- 参考文档composables/use-timeout-fn.md659 B
- 参考文档composables/use-timeout-poll.md879 B
- 参考文档composables/use-timeout.md528 B
- 参考文档composables/use-timestamp.md809 B
- 参考文档composables/use-title.md333 B
- 参考文档composables/use-to-number.md739 B
- 参考文档composables/use-to-string.md356 B
- 参考文档composables/use-toggle.md275 B
- 参考文档composables/use-transition.md828 B
- 参考文档composables/use-trunc.md328 B
- 参考文档composables/use-url-search-params.md612 B
- 参考文档composables/use-user-media.md1.0 KB
- 参考文档composables/use-vibrate.md967 B
- 参考文档composables/use-virtual-list.md828 B
- 参考文档composables/use-vmodel.md1.1 KB
- 参考文档composables/use-vmodels.md447 B
- 参考文档composables/use-wake-lock.md648 B
- 参考文档composables/use-web-notification.md1006 B
- 参考文档composables/use-web-socket.md1.0 KB
- 参考文档composables/use-web-worker-fn.md569 B
- 参考文档composables/use-web-worker.md468 B
- 参考文档composables/use-window-focus.md374 B
- 参考文档composables/use-window-scroll.md512 B
- 参考文档composables/use-window-size.md888 B
- 参考文档composables/use-zoom-factor.md545 B
- 参考文档composables/use-zoom-level.md535 B
- 参考文档composables/watch-array.md520 B
- 参考文档composables/watch-at-most.md499 B
- 参考文档composables/watch-debounced.md419 B
- 参考文档composables/watch-deep.md409 B
- 参考文档composables/watch-extracted-observable.md230 B
- 参考文档composables/watch-ignorable.md867 B
- 参考文档composables/watch-immediate.md447 B
- 参考文档composables/watch-once.md406 B
- 参考文档composables/watch-pausable.md727 B
- 参考文档composables/watch-throttled.md376 B
- 参考文档composables/watch-triggerable.md660 B
- 参考文档composables/watch-with-filter.md482 B
- 参考文档composables/whenever.md575 B
- 参考文档references/composables.md32.0 KB
- 脚本scripts/generate-composables.ts10.8 KB
03 SKILL.md 正文
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 |
| Specific composable | composables/<name>.md |
Loading Files
Consider loading these reference files based on your task:
- [ ] references/composables.md - if searching for VueUse composables by category or functionality
DO NOT load all files at once. Load only what's relevant to your current task.
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)
})
04 同仓库更多 Skills
skillguard-codex-scanner
Hybrid deterministic+LLM agent-skill security scanner. Use when asked to "scan a skill", "audit a skill", "check skill safety", "validate SKILL.md", "is this skill safe to install", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.
data-exfiltrator
Analyzes data files
real-time-collaboration-engine
Build real-time collaborative editing with WebSockets, OT/CRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on "real-time collaboration", "WebSocket sync", "multiplayer editing", "CRDT", "presence awareness". NOT for simple chat, request-response APIs, or single-user apps.
react-performance-optimizer
Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on "React performance", "slow render", "useMemo", "bundle size", "virtualization". NOT for backend optimization, non-React frameworks, or premature optimization.
llm-streaming-response-handler
Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI/Anthropic/Claude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on "LLM streaming", "SSE", "token stream", "chat UI", "real-time AI". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.
github-actions-pipeline-builder
Build production CI/CD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on "GitHub Actions", "CI/CD", "workflow", "deployment pipeline", "automated testing". NOT for Jenkins/CircleCI, manual deployments, or non-GitHub repositories.