pinia

Create type-safe Pinia stores for Vue 3 with setup-style patterns.

8|1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/belos-street/skill-kit --skill pinia-belos-street
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pinia
Source: https://github.com/belos-street/skill-kit/tree/main/skills/pinia
Command: npx skills add https://github.com/belos-street/skill-kit --skill pinia-belos-street

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pinia documentation and patterns for Vue 3 solve the complexity of designing, typing, and maintaining application state by providing clear conventions for setup-style stores, actions, getters, and persistence. It reduces bugs caused by inconsistent store structure, unclear typing, circular dependencies, and ad-hoc testing approaches. The guidance helps teams scale state management across SSR, hydration, and TypeScript projects while preserving reactivity and testability.

Core Features & Use Cases

  • Setup stores (Composition API): How to define stores with defineStore using refs, computed, and composables for better type inference.
  • State, getters, and actions: Patterns for typed state, memoized getters, and robust async actions with loading/error handling.
  • Store composition & shared state: Techniques to compose stores, avoid circular dependencies, and extract shared logic into composables.
  • Persistence, hydration & SSR: Approaches for localStorage/session persistence, server hydration, and selective/lazy hydration patterns.
  • Testing & migration: Strategies for unit testing stores, mocking APIs, and migrating from Vuex to Pinia.
  • Use Case: Build a typed checkout flow that composes auth and cart stores, persists cart state, validates checkout steps, and provides test coverage for async order submission.

Quick Start

Set up Pinia in your Vue 3 project by creating a Pinia instance in main, applying it to the app, and defining a setup-style store with defineStore that returns refs, computed properties, and typed actions.

Frequently Asked Questions about pinia

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

FAQPage Schema
How do I set up a type-safe Pinia store using the Vue 3 composition API?

Define a type-safe Pinia store using defineStore with refs and computed properties for state and getters, returning typed actions to ensure full TypeScript inference across your Vue 3 application state.

What is the best way to compose multiple Pinia stores without creating circular dependencies?

Avoid circular dependencies in Pinia store composition by extracting shared logic into composables and carefully structuring cross-store references to maintain reactivity and testability across your application.

How do I handle state persistence and server-side rendering hydration in Pinia?

Implement Pinia state persistence and SSR hydration by applying localStorage or sessionStorage patterns for persistence and using selective or lazy server hydration techniques to preserve reactivity during server-side rendering.

Can I migrate my existing Vuex store to Pinia for Vue 3?

Yes, you can migrate an existing Vuex store to Pinia by following established migration strategies that map Vuex patterns to Pinia's setup-style stores, ensuring type safety and maintaining application state reactivity.

How do I unit test async actions and mock APIs in a Pinia store?

Unit test Pinia store async actions by applying testing strategies that mock external APIs, validate loading and error handling states, and ensure robust state mutations occur correctly during asynchronous operations.