N
Nuxtβ€’5mo ago
FrontendCat

Using Pinia inside a module

Hey, I'm creating a Nuxt 3 Module right now and I want to use Pinia in it. I am having trouble integrating Pinia though. I tried adding it as a plugin like this but I don't think that's the right way to do it. Could anyone give me a hint please? πŸ™‚ module.ts
setup(moduleOptions, _nuxt) {
addPlugin(resolve('./runtime/pinia'))
}
setup(moduleOptions, _nuxt) {
addPlugin(resolve('./runtime/pinia'))
}
pinia.ts
import { useLoginStore } from './stores/login'
import { defineNuxtPlugin } from '#imports'

export default defineNuxtPlugin((_nuxtApp) => {
_nuxtApp.provide('loginStore', useLoginStore())
})
import { useLoginStore } from './stores/login'
import { defineNuxtPlugin } from '#imports'

export default defineNuxtPlugin((_nuxtApp) => {
_nuxtApp.provide('loginStore', useLoginStore())
})
2 Replies
dmarr
dmarrβ€’5mo ago
Could you use installModule ?
dmarr
dmarrβ€’5mo ago
David Marr
StackBlitz
Nuxt - Starter - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
Want results from more Discord servers?
Add your server