FrontendCat
FrontendCat
NNuxt
Created by FrontendCat on 7/22/2024 in #❓・help
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())
})
3 replies