Pinia · Stores

PINIA0001Give every Pinia store a unique id

Report possible collisions between literal store ids across the project.

Why it happens

Pinia keys every store instance by its id. The first useStore() call for an id creates the store and caches it in the Pinia instance; every later useStore() call on that Pinia instance with the same id returns that cached instance without running its own setup or options. If both definitions use that instance, the second definition is silently ignored, so callers receive the first store's state, getters, and actions.

Fix

Give each defineStore() call its own id. If both definitions describe the same store, delete one and import the remaining composable everywhere.

Example

Use one id per store

Before

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

// stores/checkout.ts
export const useCheckoutStore = defineStore('cart', () => { /* ... */ })

After

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

// stores/checkout.ts
export const useCheckoutStore = defineStore('checkout', () => { /* ... */ })

Verify the fix

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

pnpm vite-doctor . --rules pinia/stores/unique-store-id
Copyright © 2026