composables

Create Vue composables that share reactive state and lifecycle logic across components.

235|25|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/PatternsDev/skills --skill composables
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: composables
Source: https://github.com/PatternsDev/skills/tree/main/vue/composables
Command: npx skills add https://github.com/PatternsDev/skills --skill composables

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reusable composables unlock sharing Vue's reactive state and side-effect logic across multiple components, reducing duplication and improving maintainability.

Core Features & Use Cases

  • Extract and reuse common logic (e.g., useCounter, useWidth) across components to keep components focused and modular.
  • Improve testability and type safety by isolating business logic in small, focused composables.
  • Use within the Composition API setup to compose complex behavior from simple primitives.

Quick Start

Create and import reusable composables from the provided examples to start sharing logic across components.

Frequently Asked Questions about composables

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are composables in Vue and when do I need them?

Composables in Vue are functions that extract and reuse stateful logic across multiple components. You need composables when sharing reactive state and side-effects, such as counters or window width, to reduce code duplication and improve maintainability.

How do I reuse reactive state across multiple Vue components?

To reuse reactive state across Vue components, extract the shared logic into a composable using Vue's ref, onMounted, and onBeforeUnmount patterns. Import this composable into your components to consume the returned reactive state and methods.

How do I extract and share side-effect logic using the Vue Composition API?

You extract side-effect logic by creating a composable function that uses Vue's onMounted and onBeforeUnmount lifecycle hooks to manage events. This function returns reactive state and methods, allowing components to cleanly consume the shared behavior.

Does using composables improve testability for Vue state management?

Yes, using composables improves testability for Vue state management by isolating business logic into small, focused functions. This separation from the component's view layer allows you to test reactive state and methods independently.

What is the best way to organize shared counter logic in Vue?

The best way to organize shared counter logic in Vue is to create a useCounter composable. This isolates the counter state and methods within a reusable function, keeping your components focused on the view layer and modular.

Can I use composables with the Vue Composition API setup function?

Yes, you can use composables within the Vue Composition API setup function. You import the composable and call it during setup to compose complex behaviors from simple primitives, returning reactive state and methods to the component.