Open-source project
vuejs/pinia avatar
vuejs/pinia

Pinia's store contract: one name per file, arrow state, and no dynamic modules

🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support

14,764 stars1,208 forksTypeScriptMIT

At a glance

What is it?
Pinia is Vue 3's type safe store library, built on a monorepo whose v4 line dropped Vue 2, refuses dynamic modules, and ships its testing helpers and Nuxt module as separate packages.
Who is it for?
Pinia fits Vue 3 applications that want one typed store per domain and can commit to static imports. It does not fit Vue 2 codebases, Vuex stores that rely on runtime module registration, or teams expecting the README to cover persistence or test isolation.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 5 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 13, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • vuejs/pinia14,764 ★ · +39
Star history
Repository2026-09-212026-11-13
vuejs/pinia14.7k14.8k

39 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

defineStore takes an options object and a name you cannot reuse

defineStore takes an options object rather than a class or a reducer. Its first argument is the store name, which the repository states is unique across your application and will appear in devtools, so a name is an identifier with tooling attached, not just a label. The state key is a function that returns a fresh object, written as `state: () => ({ counter: 0, name: 'Eduardo' })`, so each store instance starts from a clean copy instead of sharing one module level object with every importer. Getters are optional and receive the state as their first parameter, which is why a plain arrow such as `doubleCounter: (state) => state.counter * 2` works as a one line entry. A getter that depends on a sibling getter has to be written as a method with an explicit return type, because it reaches the other entry through `this`: `doubleCounterPlusOne(): number { return this.doubleCounter + 1 }`. Actions sit in the same options object under the `actions` key.

defineStore hands back a function, and storeToRefs is what unwraps it

defineStore returns a function, not a live store, so nothing is created at import time. Access happens when that function is called, and the repository shows the call inside setup() as `const main = useMainStore()`. Returning `main` from setup hands the template the whole store, but a script that wants one field has to run it through `storeToRefs`, imported from the same package, as in `const { counter, doubleCounter } = storeToRefs(main)`. That call is what separates reactive state and getter refs from plain values that would otherwise lose reactivity when destructured. The repository example only shows this call from inside a component, and it documents no other entry point for reaching a store from a router guard, a plain module, or a worker, so code outside the setup function is off the documented path.

Dynamic modules are refused on purpose, so a Vuex port becomes static files

Pinia drops Vuex style dynamic modules deliberately, and the project answers this in one sentence: dynamic modules are not type safe, so instead it allows creating different stores that can be imported anywhere. The consequence for you is concrete: a store definition can no longer be assembled at runtime from a config array, a feature flag, or a tenant list, and any code path that used `registerModule` with a name built from a string has no Pinia equivalent. Every store becomes a static export that the bundler and the type checker both see, and the name becomes a literal in that export. The repository points at its composing stores cookbook for combining pieces, and the README itself includes no Vuex migration steps, so plan for porting a large store tree file by file.

The v4 line is Vue 3 only, and what npm ships is a build artifact

The default branch is v4 and the newest tag is v4.1.0, dated 2026-10-14. The repository states that the latest version of pinia works with Vue 3 and that Vue 2 users should move to the v2 branch, so the version number alone will not tell you which framework a copy is safe to pair with. The repository root is a private package named @pinia/root whose workspaces point at packages/*, and the build script builds packages/pinia, then packages/nuxt, then packages/testing. You install the output of packages/pinia from npm rather than this checkout, which means reading source to confirm a behaviour means navigating into packages/pinia, and changing a public type means reproducing a three package build before the change means anything to consumers.

The install line carries a second package, and skipping it kills devtools

The install snippet has two packages in it, not one:

bash
# or pnpm or yarn
npm install pinia @vue/devtools-api

Devtools support is wired through @vue/devtools-api, and the feature list names devtools support while the store name is what shows up in the panel. The comment also says pnpm or yarn work fine, yet the repository itself is a pnpm workspace with a pnpm-lock.yaml and renovate.json at the root, so pnpm, one of the options the README lists, is the one used to develop Pinia itself.

The options object stops at state, getters, and actions, with no plugin or persistence key

The store example in the repository has exactly three keys: state, getters, and actions. There is no plugin key, no subscribe hook, and no mention of writing state back to storage, so how to keep a session across reloads is not covered in the README. The Nuxt path has the same shape. The project publishes a Nuxt module, @pinia/nuxt, with 1.0.3 tagged on 2026-10-14, and the README only links to the Nuxt configuration page at pinia.vuejs.org/ssr/nuxt.html. No module block, no options list, and no description of what the module injects appear in the README, so a Nuxt user is reading the docs site to learn what the module does before writing one line of config, and the README only links a Nuxt 3 demo rather than stating which Nuxt versions the module targets.

A type change is only proven after a build, and there is no test reset in the README

The repository contains packages/testing, builds it, and runs test:dts and test:dist against it, yet the README documents no testing helper and no way to reset a store between test cases. The root test script shows the order that matters: it runs dev:prepare across the workspaces, then a type build with `tsc --build ./tsconfig.json`, then vitest with coverage, then a full build, then the dts and dist checks. A public type change is checked by tsc early in the chain and again by the dts checks after the packages are rebuilt. Formatting is handled by oxfmt rather than eslint, with `lint` set to `oxfmt --check`, and postinstall installs simple-git-hooks. Contributors cloning the repo need pnpm and a build step; consumers installing pinia from npm get none of that machinery, and the README gives no guidance on isolating state between tests, although @pinia/testing is released alongside pinia.

Editorial conclusion

Pinia fits Vue 3 applications that want one typed store per domain and can commit to static imports. It does not fit Vue 2 codebases, Vuex stores that rely on runtime module registration, or teams expecting the README to cover persistence or test isolation. Before committing, check which branch your Vue version needs, read the Nuxt module page instead of guessing its options, and confirm the devtools panel appears with the two package install.

Frequently asked questions

What is the difference between Vuex and Pinia?

The project answers this in one line: yes, Pinia is the successor of Vuex. It also states that dynamic modules are not type safe, and points instead to creating different stores that can be imported anywhere.

What is a Store in Pinia?

A store is what defineStore(name, options) describes: a state function, optional getters that read the state, and optional actions. The name is unique across the application and appears in devtools, and the call returns a function you have to call to reach the store.

how to install pinia in vue 3

Run `npm install pinia @vue/devtools-api`, create the root store with `createPinia()`, and pass it to the app with `app.use(pinia)` before `app.mount('#app')`.

how to use pinia store outside component

The function returned by defineStore is called wherever you need the store, and the repository only demonstrates that call inside setup(). It documents no separate entry point for code that is not a component.

how to use pinia in nuxt 3

The repository links a Nuxt 3 demo on StackBlitz and ships its own Nuxt module, @pinia/nuxt, whose 1.0.3 tag is dated 2026-10-14. The module configuration is not printed in the README, only linked at https://pinia.vuejs.org/ssr/nuxt.html.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. vuejs/pinia on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/vuejs-pinia.svg)](https://hysenlabs.com/projects/vuejs-pinia)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/vuejs-pinia.svg)](https://hysenlabs.com/projects/vuejs-pinia)

Was this useful?