Pinia · Stores

PINIA0002Name store composables after their id

Name the variable that receives defineStore() use<Id>Store, matching the literal store id.

Why it happens

Pinia's convention is to name the defineStore() return value use followed by the store id and Store. When the composable name and the id drift apart, Devtools, SSR state keys, and HMR show an id that nobody can find by searching for the composable, and two stores can end up sharing an id unnoticed.

Fix

Rename the composable to use<Id>Store, or change the id so it describes the store the composable returns. Kebab-case, snake_case, and camelCase ids map to the same PascalCase name, so 'shopping-cart' and 'shoppingCart' both expect useShoppingCartStore.

Example

Match the composable name to the store id

Before

export const useBasket = defineStore('cart', () => {
  /* ... */
})

After

export const useCartStore = defineStore('cart', () => {
  /* ... */
})

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --extends auto,pinia/strict --rules pinia/stores/store-name-matches-id
Copyright © 2026