Skip to content
Skillpedia
Websites & UI (frontend)6.0k · #14442

pinia

What it does

This skill explains how to organize shared data in Vue apps using Pinia, the official state library for Vue. It is for developers who need the same data in many parts of an app.

When to use it

  • ✓When you are building a Vue app and need data shared across many components.
  • ✓When you want to set up stores with state, getters and actions.
  • ✓When you need to test or extend a Pinia store.

Skill link

https://github.com/antfu/skills/blob/main/skills/pinia/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/antfu/skills/blob/main/skills/pinia/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Create a Pinia store that keeps my shopping cart items and totals across all pages.”

5 new skills a week. 1 minute to read.

How it works

The agent sets up stores that hold shared data and the actions that change it, following Pinia's guidance on types, testing and extensions.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Pinia

Pinia is the official state management library for Vue, designed to be intuitive and type-safe. It supports both Options API and Composition API styles, with first-class TypeScript support and devtools integration.

The skill is based on Pinia v4.0.3, generated at 2026-09-25.

Core References

Topic Description Reference
Stores Defining stores, state, getters, actions, storeToRefs, subscriptions core-stores

Features

Extensibility

Topic Description Reference
Plugins Extend stores with custom properties, state, and behavior features-plugins

Composability

Topic Description Reference
Composables Using Vue composables within stores (VueUse, etc.) features-composables
Composing Stores Store-to-store communication, avoiding circular dependencies features-composing-stores

Best Practices

Topic Description Reference
Testing Unit testing with @pinia/testing, mocking, stubbing best-practices-testing
Outside Components Using stores in navigation guards, plugins, middlewares best-practices-outside-component

Advanced

Topic Description Reference
SSR Server-side rendering, state hydration advanced-ssr
Nuxt Nuxt integration, auto-imports, SSR best practices advanced-nuxt
HMR Hot module replacement for development advanced-hmr

Key Recommendations

  • Prefer Setup Stores for complex logic, composables, and watchers
  • Use storeToRefs() when destructuring state/getters to preserve reactivity
  • Actions can be destructured directly - they're bound to the store
  • Call stores inside functions not at module scope, especially for SSR
  • Add HMR support to each store for better development experience
  • Use @pinia/testing for component tests with mocked stores
FAQ

Is Pinia only for Vue?

It is built for Vue apps, which is what the guidance covers.

Can I test my stores?

Yes. The guidance covers testing and mocking stores.

Does it work with TypeScript?

Yes. Pinia is designed to be type-safe and supports TypeScript.

Details

Original description by the author

Pinia official Vue state management library, type-safe and extensible. Use when defining stores, working with state/getters/actions, or implementing store patterns in Vue apps.

repo: antfu/skills

Popularity

GitHub stars
6.0k
Ranking position
#14442
License
MIT
Updated
10/30/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills