Manage shared Vue state with Pinia stores

8 steps · about 1 h 55 min · Intermediate

  1. Decide when Vue state needs a store (article, Vue.js, 15 min)

    Shows the problem a store solves before you add one.

  2. See what Pinia adds over a plain reactive object (article, Pinia, 10 min)

    Lists devtools, plugins, SSR and typing benefits in one page.

  3. Define a store with options or setup syntax (reference, Pinia, 15 min)

    Covers defineStore, store naming and destructuring with storeToRefs.

  4. Read, reset and patch store state (reference, Pinia, 15 min)

    Explains $patch, $reset and subscribing to state changes.

  5. Derive values with getters (reference, Pinia, 10 min)

    Shows cached computed values and getters that use other stores.

  6. Put async logic in actions (reference, Pinia, 15 min)

    Covers async actions, calling other stores and $onAction hooks.

  7. Persist or extend every store with a plugin (tutorial, Pinia, 15 min)

    A worked way to add shared behaviour such as local persistence.

  8. Unit test stores and components that use them (tutorial, Pinia, 20 min)

    Shows createTestingPinia and how to stub actions in tests.