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.
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) {
},
}
})
-
-declare module 'pinia' {
- export interface PiniaCustomProperties {
- /**
- * Nuxt context.
- */
- // FIXME: where is this type?
- // $nuxt: import('@nuxt/types').Context
- }
-}