[Vuejs]-Create global helper / mixin Nuxt 3

0👍

If you would like to provide a helper on the NuxtApp instance, return it from the plugin under a provide key.

export default defineNuxtPlugin((nuxtApp) => {
    return {
          provide: {
               register: register
          }
    }
})

In another file you can use this:

<template>
  <div>
  </div>
</template>
<script setup lang="ts">
const { $register } = useNuxtApp()
</script>

For more details: nuxt3 plugins docs.

Leave a comment