NuxtN
Nuxtโ€ข2y 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'))
 }


pinia.ts
import { useLoginStore } from './stores/login'
import { defineNuxtPlugin } from '#imports'

export default defineNuxtPlugin((_nuxtApp) => {
  _nuxtApp.provide('loginStore', useLoginStore())
})
Was this page helpful?