create-adaptable-composable

Installation
Summary

Library-grade Vue composables that accept plain values, refs, or getters as inputs.

  • Use MaybeRefOrGetter for read-only inputs (computed-friendly) and MaybeRef for writable two-way inputs; normalize with toValue() or toRef() inside reactive effects
  • Normalize inputs using toRef() for watcher sources and toValue() for non-reactive resolution to keep behavior predictable across different input types
  • Avoid MaybeRefOrGetter when parameters are callbacks, predicates, or comparators to prevent accidental function invocation as getters
  • Requires Vue 3+ or Nuxt 3+
SKILL.md

Create Adaptable Composable

Adaptable composables are reusable functions that can accept both reactive and non-reactive inputs. This allows developers to use the composable in a variety of contexts without worrying about the reactivity of the inputs.

Steps to design an adaptable composable in Vue.js:

  1. Confirm the composable's purpose and API design and expected inputs/outputs.
  2. Identify inputs params that should be reactive (MaybeRef / MaybeRefOrGetter).
  3. Use toValue() or toRef() to normalize inputs inside reactive effects.
  4. Implement the core logic of the composable using Vue's reactivity APIs.

Core Type Concepts

Type Utilities

/**
 * value or writable ref (value/ref/shallowRef/writable computed)
 */
export type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
Related skills
Installs
6.1K
Repository
vuejs-ai/skills
GitHub Stars
2.4K
First Seen
Jan 28, 2026