recaptcha-module icon indicating copy to clipboard operation
recaptcha-module copied to clipboard

is this compatible with nuxt v3 ?

Open morteza-mortezai opened this issue 2 years ago • 10 comments

hi can we use this module with nuxt version 3 ?

morteza-mortezai avatar Sep 17 '22 16:09 morteza-mortezai

hi

can we use this module with nuxt version 3 ?

Hey! Unfortunately not:(

mvrlin avatar Sep 17 '22 17:09 mvrlin

hi can we use this module with nuxt version 3 ?

hi can we use this module with nuxt version 3 ?

Hey! Unfortunately not:(

you can use vue-recaptcha and create a global compenent using nuxt 3 plugins it works for me

mohammedmoutawakkil avatar Oct 05 '22 15:10 mohammedmoutawakkil

hi can we use this module with nuxt version 3 ?

You can create Nuxt Plugin but first install vue-recaptcha package/lib

npm i --save vue-recaptcha

If this gave an error try to install with try to add --force flag

npm i --save vue-recaptcha --force

In plugins directory create file recaptcha.ts

Paste this code in recaptcha.ts

import {defineNuxtPlugin} from "#app";
import {VueRecaptcha} from "vue-recaptcha";

export default defineNuxtPlugin((nuxtApp)=> {
    nuxtApp.vueApp.component('VueRecaptcha', VueRecaptcha)
})

Inside your component

<template>
   ...
   <VueRecaptcha
       sitekey="YOUR_SITE_KEY"
       :loadRecaptchaScript="true"
       @verify="verifyRecaptcha"
       @expired="expiredRecaptcha"
   />
   ...
</template>

Here's the complete docs

waleedtariq109 avatar Nov 02 '22 10:11 waleedtariq109

hi @WaleedTariq109 thanks for the code, can you show me the verifyRecaptcha function? how do you get the API response from Google? Did you have CORS problem? is this for recaptcha v2 or v3?

also @mohammedmoutawakkil can you share your code? that'd be great and help me a lot

thanks before guys

edwinsenjaya avatar Nov 10 '22 09:11 edwinsenjaya

I found this issue while Googling this problem. There are several attempts floating around to get reCaptcha working with Nuxt 3. This is the one I ended up using.

https://github.com/AurityLab/vue-recaptcha-v3/issues/609

You can see my implementation of that library in this pull request.

https://github.com/dan-bowen/nuxt-blog-starter/pull/8

That being said... I hope the community will be able to rally around an updated reCaptcha plugin now that Nuxt 3 is stable.

dan-bowen avatar Nov 17 '22 02:11 dan-bowen

I found this issue while Googling this problem. There are several attempts floating around to get reCaptcha working with Nuxt 3. This is the one I ended up using.

https://github.com/AurityLab/vue-recaptcha-v3/issues/609

You can see my implementation of that library in this pull request.

https://github.com/dan-bowen/nuxt-blog-starter/pull/8

That being said... I hope the community will be able to rally around an updated reCaptcha plugin now that Nuxt 3 is stable.

I am working on that 😉

mvrlin avatar Nov 17 '22 06:11 mvrlin

Hello, is this still in the works?

felixrydberg avatar Mar 03 '23 18:03 felixrydberg

Hi, I'm the author of vue-recaptcha. vue-recaptcha v3 is in alpha and has natively Nuxt integration. I hope could get some feedback.

DanSnow avatar Mar 25 '23 12:03 DanSnow

hi can we use this module with nuxt version 3 ?

You can create Nuxt Plugin but first install vue-recaptcha package/lib

npm i --save vue-recaptcha

If this gave an error try to install with try to add --force flag

npm i --save vue-recaptcha --force

In plugins directory create file recaptcha.ts

Paste this code in recaptcha.ts

import {defineNuxtPlugin} from "#app";
import {VueRecaptcha} from "vue-recaptcha";

export default defineNuxtPlugin((nuxtApp)=> {
    nuxtApp.vueApp.component('VueRecaptcha', VueRecaptcha)
})

Inside your component

<template>
   ...
   <VueRecaptcha
       sitekey="YOUR_SITE_KEY"
       :loadRecaptchaScript="true"
       @verify="verifyRecaptcha"
       @expired="expiredRecaptcha"
   />
   ...
</template>

Here's the complete docs

Hey @waleedtariq109 thank you! I wasn't using reCaptcha but was trying to get hCaptcha to work, and your code helped me understand the component registration part of the plugin was the missing link.

Here was my code for vue-hCaptcha in case it helps anyone else:

In your vue file

<vue-hcaptcha
sitekey="xxxx" 
></vue-hcaptcha>

Then in plugins\vue-hcaptcha.js:

import { defineNuxtPlugin } from "#app";
import VueHcaptcha from '@hcaptcha/vue3-hcaptcha'

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.component('vue-hcaptcha', VueHcaptcha)
})

ohkeenan avatar Apr 10 '23 01:04 ohkeenan

Check out this comment

fahmifitu avatar May 03 '23 06:05 fahmifitu