pinia

Implement type-safe state management stores in Vue applications using Pinia.

Updated Aug 2, 2026
One-click install
npx skills add https://github.com/jeje-it/template-projet --skill pinia-jeje-it
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: pinia
Source: https://github.com/jeje-it/template-projet/tree/main/.agents/skills/pinia
Command: npx skills add https://github.com/jeje-it/template-projet --skill pinia-jeje-it

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Managing shared state across Vue components becomes error-prone with ad-hoc solutions, leading to lost reactivity, SSR hydration bugs, and untestable code. This Skill provides authoritative guidance on Pinia, the official Vue state management library, covering store definition, testing, SSR, and plugin extension. ## Core Features & Use Cases - Store Definition Patterns: Define Option Stores and Setup Stores with state, getters, and actions, including TypeScript typing and storeToRefs for safe destructuring. - Testing Support: Unit test stores with setActivePinia and test components using @pinia/testing with stubbed actions, initial state, and mocked getters. - SSR & Nuxt Integration: Handle server-side rendering, state hydration with devalue, and Nuxt auto-imports without cross-request state pollution. - Use Case: When building a Vue 3 app with an authentication flow, use this Skill to create a user store with async login actions, persist state via a plugin, and write component tests with mocked store actions. ## Quick Start Ask the AI to create a Pinia setup store for shopping cart state with actions to add items and persist the cart to localStorage.

Frequently Asked Questions about pinia

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

FAQPage Schema
How do I define a store in Pinia with TypeScript?▼

Define a Pinia store using defineStore with a unique name, choosing either Option Stores with state/getters/actions or Setup Stores using ref and computed. TypeScript inference works automatically, and you can annotate state with interfaces for complex types.

How to test Pinia stores and components with Vitest?▼

Test stores by calling setActivePinia(createPinia()) in beforeEach, then invoke actions and assert state directly. For components, install @pinia/testing and use createTestingPinia, which stubs actions by default and lets you set initial state.

Why does destructuring a Pinia store break reactivity?▼

Destructuring state or getters directly from a store extracts raw values and loses reactivity. Use storeToRefs(store) to extract state and getters as refs, while actions can be destructured directly since they are bound to the store.

Does Pinia work with Nuxt and server-side rendering?▼

Pinia supports SSR and integrates with Nuxt via the @pinia/nuxt module, which auto-imports stores and handles serialization. For manual SSR, hydrate state on the client before any useStore call and pass the pinia instance when using stores outside components.

Can I use VueUse composables inside Pinia stores?▼

Setup Stores can use almost any composable, such as useLocalStorage or useMediaControls from VueUse. Option Stores only support composables returning writable refs in state, and SSR requires hydrate() or skipHydrate() for client-only state.

Why does calling useStore at module scope fail?▼

Calling useStore before the pinia instance is installed on the app throws an error because no active pinia exists. Defer useStore calls to functions like navigation guards or setup, and pass the pinia instance explicitly in SSR contexts.