vue-pinia-best-practices

Standardize Pinia store setup and reactivity for Vue 3 applications.

Updated Feb 7, 2026
One-click install
npx skills add https://github.com/jd-solanki/lekhan-internal-sync --skill vue-pinia-best-practices-jd-solanki
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue-pinia-best-practices
Source: https://github.com/jd-solanki/lekhan-internal-sync/tree/main/.agents/skills/vue-pinia-best-practices
Command: npx skills add https://github.com/jd-solanki/lekhan-internal-sync --skill vue-pinia-best-practices-jd-solanki

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill consolidates Pinia best practices for Vue 3 applications, helping teams implement consistent, scalable state management with predictable reactivity and robust store patterns.

Core Features & Use Cases

  • Guided store setup: Clear patterns for defining and using Pinia stores (setup stores and options-style stores).
  • Reactivity correctness: Guidance on using storeToRefs and proper template bindings to maintain UI reactivity.
  • Best-practice patterns: Common gotchas, recommended conventions, and migration tips for larger apps.

Quick Start

Install and configure Pinia in a Vue 3 project, then follow the examples in the reference files to implement a sample store and reactive components.

Frequently Asked Questions about vue-pinia-best-practices

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

FAQPage Schema
How do I maintain reactivity when using Pinia stores in Vue 3 components?

To maintain reactivity in Vue 3, destructure Pinia store state using the storeToRefs function. This ensures reactive properties remain connected to the store, while actions can be safely destructured directly without losing reactivity.

What is the best way to structure Pinia setup stores for scalable Vue apps?

The best way to structure scalable Pinia setup stores is by returning all state and actions from the setup function. This pattern enforces consistent state management and predictable reactivity across mid-to-large-scale Vue 3 applications.

Why does my Vue 3 component lose reactivity when destructuring Pinia store properties?

Vue 3 components lose Pinia reactivity when state is destructured directly. Wrap the store with storeToRefs before destructuring to preserve reactive connections, ensuring safe template binding and reliable UI updates.

Can I use setup stores and options stores together in a Pinia project?

Yes, Pinia supports both setup stores and options-style stores in the same Vue 3 project. This skill provides guided patterns for defining and using both store types to achieve consistent, maintainable state management.

When do I need storeToRefs for Pinia template bindings in Vue 3?

You need storeToRefs for Pinia template bindings whenever you destructure state outside the store. It extracts reactive properties safely, maintaining UI reactivity across Vue 3 components while keeping template usage predictable.