---
title: "Pinia"
description: "Diagnose Pinia store definitions with the Pinia Rule Pack."
canonical_url: "https://vite-doctor.onmax.me/pinia"
---
# Pinia

> Diagnose Pinia store definitions with the Pinia Rule Pack.

The Pinia Rule Pack checks `defineStore()` calls in Vue, Vite, and Nuxt projects. Pinia is a Vue ecosystem library rather than part of Vue or Nuxt, so the pack activates on its own when Project Inventory contains `pinia` or `@pinia/nuxt`.

## Install and run

Install Vite Doctor in the project:

```bash
pnpm add -D vite-doctor
```

The Recommended Preset runs automatically and reports store ids that more than one `defineStore()` call registers:

```bash
pnpm vite-doctor .
```

The Strict Preset adds the `use<Id>Store` naming convention:

```bash
pnpm vite-doctor . --extends auto,pinia/strict
```

To diagnose one Rule, select it with `--rules`. Strict-only Rules also need the Strict Preset:

```bash
pnpm vite-doctor . --rules pinia/stores/unique-store-id
pnpm vite-doctor . --extends auto,pinia/strict --rules pinia/stores/store-name-matches-id
```

## What Doctor reads

Doctor recognizes `defineStore` imported from `pinia`, including aliased and namespace imports. It also recognizes `defineStore` with no import, which is how `@pinia/nuxt` and `unplugin-auto-import` expose it. Calls whose callee resolves to a local declaration or parameter are skipped, including shadowed named, aliased, and namespace imports.

Doctor only compares ids that are string literals, or template literals without expressions. Both `defineStore('cart', ...)` and the object form `defineStore({ id: 'cart', ... })` are read. Ids built from variables or expressions are skipped.

Duplicate ids are compared across the files Doctor scans by default, so tests, fixtures, and generated files are excluded. The comparison spans workspace packages because stores imported from another package can share the app’s Pinia instance. Diagnostics have heuristic confidence: duplicate ids collide only when their definitions use the same Pinia instance. Doctor does not prove that runtime relationship; independent instances can intentionally reuse ids.

---

- [Pinia rules](https://vite-doctor.onmax.me/pinia/rules)
- [Defining a store](https://pinia.vuejs.org/core-concepts/#Defining-a-Store)


## Sitemap

See the full [sitemap](https://vite-doctor.onmax.me/sitemap.md) for all pages.
