Skip to content

Commit

Permalink
feat(nuxt): remove wrong $nuxt in Nuxt 3
Browse files Browse the repository at this point in the history
BREAKING CHANGE: in Nuxt 3, `$nuxt` is no longer available in stores.
This is because it was removed in Nuxt 3 and it is no longer the
_context_ as it used to be. Most of the features used there, like
`$fetch` are now globally available and therefore remove the need of it.
You can also use
[`useNuxtApp()`](https://v3.nuxtjs.org/bridge/bridge-composition-api/)
when necessary.
  • Loading branch information
posva committed Jul 13, 2022
1 parent 78fcf76 commit 67e5417
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions packages/nuxt/src/runtime/plugin.vue3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(pinia)
setActivePinia(pinia)

// @ts-expect-error: _p is internal
pinia._p.push(({ store }) => {
// make it non enumerable so it avoids any serialization and devtools
Object.defineProperty(store, '$nuxt', { value: nuxtApp })
})

if (process.server) {
nuxtApp.payload.pinia = pinia.state.value
} else if (nuxtApp.payload && nuxtApp.payload.pinia) {
Expand All @@ -25,13 +19,3 @@ export default defineNuxtPlugin((nuxtApp) => {
},
}
})

declare module 'pinia' {
export interface PiniaCustomProperties {
/**
* Nuxt context.
*/
// FIXME: where is this type?
// $nuxt: import('@nuxt/types').Context
}
}

0 comments on commit 67e5417

Please sign in to comment.