N
Nuxt7mo ago
BT1010

call composable from setup globally from nuxt3 layer

In my nuxt3 layer I have my own composable which is using useReCaptcha composable. (https://github.com/AurityLab/vue-recaptcha-v3) This composable must be executed from the setup therefore my own composable also needs to be executed from setup. However as this is something I always want to run when app starts on the client, I currently have it inside app.vue within the layer like this:
<script setup>
import { useCaptcha } from '@/composables/useCaptcha.ts'

if (process.client) {
const { createChallengeCookie } = useCaptcha()
createChallengeCookie()
}
</script>

<template>
<NuxtPage />
</template>
<script setup>
import { useCaptcha } from '@/composables/useCaptcha.ts'

if (process.client) {
const { createChallengeCookie } = useCaptcha()
createChallengeCookie()
}
</script>

<template>
<NuxtPage />
</template>
But this is app.vue inside a layer. I don't want to have app.vue in the layer. I want to have app.vue in the app where I use this layer. Where elsewhere I can call useCaptcha ? I want to keep execution of this composable within the layer
GitHub
GitHub - AurityLab/vue-recaptcha-v3: A simple and easy to use reCAP...
A simple and easy to use reCAPTCHA (v3 only) library for Vue. - AurityLab/vue-recaptcha-v3
1 Reply
BT1010
BT10107mo ago
but isn't setup in the plugin something totally different than vue3 setup hook? I need to call the recaptcha init on the setup of vue3 lifecycle
Want results from more Discord servers?
Add your server