NuxtN
Nuxt2y ago
Patrik.S

option api - useNuxtApp

Hello, I’m migrating bigger project from nuxt2 to 3 🙈, and I found out that I don’t know how to call plugin in option api.

The plugin looks like this:

export default defineNuxtPlugin((nuxtApp) => {
  return {
    provide: {
      hello: () => `Hello`
    }
  }
})


I know i can get $hello in setup:

const { $hello } = useNuxtApp()


But the question is how can I get the $hello in option API - I don’t like calling it at every method.

At nuxt2 a just call it in method like ‘this.$hello’ and I had full context.

Is there any elegant solution for this?

Thanks for any advice!
Was this page helpful?