vue-pinia-best-practices

Codify Pinia best practices for Vue 3 state management and SSR contexts.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Jozaguts/futzo --skill vue-pinia-best-practices-jozaguts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue-pinia-best-practices
Source: https://github.com/Jozaguts/futzo/tree/main/.codex/skills/vue-pinia-best-practices
Command: npx skills add https://github.com/Jozaguts/futzo --skill vue-pinia-best-practices-jozaguts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pinia best practices address common pitfalls in Vue 3 state management, helping teams write robust, scalable stores and avoid reactivity issues, SSR pitfalls, and misused actions or getters.

Core Features & Use Cases

  • Guidance on Store Setup, including correct Pinia installation order and returning state from setup stores.
  • Reactivity and destructuring best practices, including when to use storeToRefs and how to keep UI reactive.
  • State patterns, conventions for state, getters, and actions, plus debugging and common gotchas.

Quick Start

Apply the Pinia best practices across your Vue 3 projects to avoid common pitfalls.

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 keep reactivity when destructuring a Pinia store in Vue 3?

To keep reactivity when destructuring a Pinia store in Vue 3, use the storeToRefs function. It wraps state and getters, ensuring destructured properties remain reactive in templates and setup contexts.

What is the correct Pinia installation order for Vue 3 applications?

Correct Pinia installation order requires installing the Pinia plugin on the Vue 3 app instance before mounting it. Proper setup ensures stores are available throughout the component tree and prevents SSR hydration mismatches.

What's the best way to structure setup stores using Pinia?

The best way to structure Pinia setup stores is using composition API syntax, defining state as refs and returning all state, getters, and actions explicitly. This ensures correct store structure and safe usage in templates.

Do I need to handle Pinia state management differently for SSR in Vue 3?

Yes, Pinia state management for SSR in Vue 3 requires special attention to avoid common pitfalls. You must ensure correct store initialization and hydration per request to prevent cross-request state pollution.

Why does my Pinia store action or getter break in a large Vue app?

Pinia store actions or getters may break in large Vue apps due to misused reactivity patterns or incorrect destructuring without storeToRefs. Following best practices for state conventions and debugging resolves these gotchas.