Manage shared Vue state with Pinia stores
8 steps · about 1 h 55 min · Intermediate
- Decide when Vue state needs a store (article, Vue.js, 15 min)
Shows the problem a store solves before you add one.
- See what Pinia adds over a plain reactive object (article, Pinia, 10 min)
Lists devtools, plugins, SSR and typing benefits in one page.
- Define a store with options or setup syntax (reference, Pinia, 15 min)
Covers defineStore, store naming and destructuring with storeToRefs.
- Read, reset and patch store state (reference, Pinia, 15 min)
Explains $patch, $reset and subscribing to state changes.
- Derive values with getters (reference, Pinia, 10 min)
Shows cached computed values and getters that use other stores.
- Put async logic in actions (reference, Pinia, 15 min)
Covers async actions, calling other stores and $onAction hooks.
- Persist or extend every store with a plugin (tutorial, Pinia, 15 min)
A worked way to add shared behaviour such as local persistence.
- Unit test stores and components that use them (tutorial, Pinia, 20 min)
Shows createTestingPinia and how to stub actions in tests.