# Pinia — card for AI agents

Intuitive, type-safe state management store for Vue applications.

Category: State and data fetching · npm package `pinia` · latest version 4.1.0 (checked 2026-11-01)
Install: `npm install pinia`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Pinia
- Install with the README's command: `npm install pinia @vue/devtools-api`. pnpm or yarn also work.
- Create a pinia (the root store) with `createPinia()` and pass it to the app with `app.use(pinia)`.
- Put each store in its own file. Define it with `defineStore('name', {...})`, and keep the name unique across the app, because it appears in devtools.
- Write `state` as a function that returns a fresh state. Getters and actions are optional. Getters receive the state as their first parameter, and inside actions `this` is the store instance.
- `defineStore` returns a function. Call it, for example `useMainStore()`, to get access to the store.
- To extract specific state or getters from a store, use `storeToRefs(store)`, as the README does.
- Do not reach for dynamic modules. Create separate stores and import them where needed. The latest version targets Vue 3; for Vue 2, use the `v2` branch.

## Agent Skills for it
- pinia from antfu/skills: `npx skills add antfu/skills --skill pinia`

## What it is
- Pinia is a state store for Vue. The GitHub repository describes it as an "Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support". It is MIT licensed, and the repository was created on 2019-11-18. In its FAQ, the README answers yes when asked whether Pinia is the successor of Vuex.
- You create one root pinia with `createPinia()` and pass it to the app with `app.use(pinia)`. Each store is declared with `defineStore`, which takes a name that is unique across the app, a state function, optional getters and optional actions. It returns a function that you call inside a component to get the store. The website says you can "Build multiple stores and let your bundler code split them automatically."
- The latest version works with Vue 3, and a `v2` branch covers Vue 2. The README lists a Nuxt Module among its features. It links two StackBlitz demos, one with Vue 3 and Vite and one with Nuxt 3.

## Caveats
- Vue 2 lives on another branch: The README says the latest pinia works with Vue 3. For Vue 2, it points to the `v2` branch.
- No dynamic modules: The README says dynamic modules are not type safe. Instead, the maintainers allow creating different stores that can be imported anywhere.
- Install command names two packages: The README's install command adds `@vue/devtools-api` alongside `pinia`.
- SSR fix for Set and Map state: The `@pinia/nuxt@1.0.2` release notes list an SSR bug fix: reactive Set/Map state is now replaced on hydration instead of being unioned. The notes do not say which `pinia` package version contains it.

## Numbers (AgentGid data)
- Gid Score: 67.1 (#544 of all tools, 15 of 53 in its category)
- Used in 56 public projects set up for AI coding agents (0.9%)
- Downloads last week: 7,860,566 (as of 2026-11-24), +47.2% over 4 weeks
- GitHub stars: 14,772 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
Vue 98.2%, vue-tsc 69.6%, Vite 69.6%, VueUse 53.6%, ESLint 80.4%, Day.js 33.9%

## Checked alternatives (same job)
- Zustand: https://agentgid.com/tools/zustand/agent.md
- Jotai: https://agentgid.com/tools/jotai/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/pinia/
- Homepage: https://pinia.vuejs.org
- Repository: https://github.com/vuejs/pinia
- Source: https://github.com/vuejs/pinia#readme
- Source: https://github.com/vuejs/pinia
- Source: https://github.com/vuejs/pinia/releases
- Source: https://pinia.vuejs.org

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
