Skip to content

docs: add devtools v3 compatibility note #2923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/docs/cookbook/migration-v2-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ This deprecated type alias has been removed in favor of `PiniaPlugin`.
- TypeScript 5 or newer is required.
- The devtools API has been upgraded to [v7](https://devtools.vuejs.org).

> [!NOTE]
> To use Pinia with Devtools v6, use Pinia 2

## Nuxt

The Nuxt module has been updated to support Nuxt 3. If you are using Nuxt 2 or Nuxt bridge, you can keep using the old version of Pinia.
3 changes: 3 additions & 0 deletions packages/pinia/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ See the [migration guide](https://pinia.vuejs.org/cookbook/migration-v2-v3.html)
- `defineStore({ id: 'id' })` is now removed. Use `defineStore('id')` instead
- Pinia is now published as a `type: module` package but it still provides CJS versions dist files

> [!NOTE]
> Pinia >= 3.0.0 is only compatible with Vue Devtools v7. To use Pinia with Devtools v6, use Pinia 2

### Code Refactoring

- remove deprecated aliases ([87c6182](https://github.com/vuejs/pinia/commit/87c6182c4bf61e1f96a4877eb884fd59cf824e1f))
Expand Down
15 changes: 15 additions & 0 deletions packages/pinia/src/devtools/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ interface TimelineEvent<TData = any, TMeta = any> {
*/
const getStoreType = (id: string) => '🍍 ' + id

/**
* Check if Vue DevTools is legacy
*/
function isLegacyVueDevTools() {
return (
+(globalThis.__VUE_DEVTOOLS_GLOBAL_HOOK__.devtoolsVersion?.[0] ?? 0) < 7
)
}

/**
* Add the pinia plugin without any store. Allows displaying a Pinia plugin tab
* as soon as it is added to the application.
Expand All @@ -60,6 +69,12 @@ const getStoreType = (id: string) => '🍍 ' + id
* @param pinia - pinia instance
*/
export function registerPiniaDevtools(app: App, pinia: Pinia) {
if (isLegacyVueDevTools()) {
toastMessage(
'Pinia >= 3.0.0 is only compatible with Vue Devtools v7. To use Pinia with Devtools v6, use Pinia 2',
'warn'
)
}
setupDevtoolsPlugin(
{
id: 'dev.esm.pinia',
Expand Down