Pinia is an intuitive, type-safe, and flexible state management library specifically designed for Vue.js applications. It serves as a lightweight and robust alternative to Vuex, leveraging Vue 3's Composition API for a more modern and streamlined development experience. The current stable major version is v3.x, with the latest release being v3.0.4, indicating active maintenance and minor updates within the major release. Pinia distinguishes itself through its excellent TypeScript support, providing strong type inference out-of-the-box, automatic module generation (no need for nested modules), and a plugin system. Its API is designed to be straightforward and familiar to Vue developers, making state management less verbose and more declarative. Releases within a major version (like v3.0.x) typically include bug fixes and minor improvements, with major version bumps (v2 to v3) often aligning with Vue major version releases and dropping support for older ecosystems (e.g., Vue 2).
npm install piniaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up Pinia in a Vue 3 application, define a basic store with state, getters, and actions, and use it within a Vue component.
Upgrade your Vue application to Vue 3 or stick to Pinia v2.x. Refer to the official migration guide for v2 to v3.
Update your project's TypeScript dependency to 4.5.0 or newer (e.g., `npm install -D typescript@latest`).
Consult the Pinia v3 documentation on writing plugins. The migration guide from v2 to v3 provides details on this change.
Always initialize and install Pinia as a Vue plugin (`app.use(createPinia())`) at the root of your application before any component that consumes a store is mounted.
Ensure `app.use(createPinia())` is called correctly on your Vue application instance before mounting.
Add `app.use(createPinia())` to your application's entry point before any component using Pinia is initialized.
Upgrade TypeScript to version 4.5.0 or higher in your project dependencies (`npm install -D typescript@latest`).