vue-pinia-best-practices

Apply Pinia best practices for Vue 3 state management.

Updated Jan 29, 2026
One-click install
npx skills add https://github.com/trcat/ai-todo-list --skill vue-pinia-best-practices-trcat
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue-pinia-best-practices
Source: https://github.com/trcat/ai-todo-list/tree/main/.agents/skills/vue-pinia-best-practices
Command: npx skills add https://github.com/trcat/ai-todo-list --skill vue-pinia-best-practices-trcat

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pinia best practices, common gotchas, and state management patterns for Vue 3 applications.

Core Features & Use Cases

  • Guidance on proper setup stores, storeToRefs usage, and avoiding common reactivity pitfalls.
  • Patterns & Checks for destructuring, binding, and SSR compatibility.
  • Use Case: When starting a large Vue 3 project, apply these patterns to ensure maintainable state management and fewer runtime errors.

Quick Start

Read and implement recommended patterns in your project. For deeper learning, consult the linked references in the repository.

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 prevent reactivity loss when destructuring Pinia stores in Vue 3?

To prevent reactivity loss when destructuring Pinia stores in Vue 3, use the `storeToRefs` function to extract state and getters, ensuring reactive references remain intact in your components.

What is the best way to structure Pinia setup stores for Vue 3 state management?

The best way to structure Pinia setup stores is to define state as `ref` or `reactive` variables and return them explicitly, enabling flexible composition and predictable state management patterns in Vue 3.

Why does my Pinia state stop updating the UI in Vue 3 components?

Pinia state stops updating the UI when properties are destructured directly without `storeToRefs`, breaking the reactive connection. Use `storeToRefs` for state and getters to maintain UI updates.

Can I use Pinia setup stores for server-side rendering in Vue 3?

Yes, you can use Pinia setup stores for SSR in Vue 3, but you must follow specific compatibility patterns to avoid shared state pollution across requests by properly initializing and hydrating store instances.

What are common Pinia gotchas when starting a large Vue 3 project?

Common Pinia gotchas in large Vue 3 projects include improper storeToRefs usage causing reactivity loss, incorrect destructuring of actions, and failing to follow SSR compatibility patterns, which lead to runtime errors.

When do I need to use storeToRefs instead of directly accessing the Pinia store?

You need to use `storeToRefs` whenever you want to destructure state or getters from a Pinia store while preserving their reactivity. Direct access without it is safe only for calling actions.