N
Nuxtβ€’2y ago
toni

How to add plugins to @pinia/nuxt?

Not sure if I'm stupid, but I can't figure out how to register plugins with @pinia/nuxt...
2 Replies
Cue
Cueβ€’2y ago
Through one or more plugins...
export default defineNuxtPlugin(() => {
useNuxtApp().$pinia.use(...)
})
export default defineNuxtPlugin(() => {
useNuxtApp().$pinia.use(...)
})
Or if using TS (see https://github.com/vuejs/pinia/issues/2071):
import type { Pinia } from 'pinia'

export default defineNuxtPlugin(() => {
(useNuxtApp().$pinia as Pinia).use(...)
})
import type { Pinia } from 'pinia'

export default defineNuxtPlugin(() => {
(useNuxtApp().$pinia as Pinia).use(...)
})
GitHub
Issues Β· vuejs/pinia
🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support - Issues · vuejs/pinia
toni
toniOPβ€’2y ago
Thanks a lot @cuebit πŸ™πŸ½

Did you find this page helpful?