Vue reCAPTCHA-v3
A simple and easy to use reCAPTCHA (v3 only) library for Vue based on reCAPTCHA-v3.
Install
With NPM:
$ npm install vue-recaptcha-v3
With Yarn:
$ yarn add vue-recaptcha-v3
Prerequisites
To use this package you only need a valid site key for your domain, which you can easily get here.
Usage
import Vue from 'vue'
import { VueReCaptcha } from 'vue-recaptcha-v3'
Vue.use(VueReCaptcha, { siteKey: '<site key>' })
new Vue({
methods: {
async recaptcha() {
await this.$recaptchaLoaded()
const token = await this.$recaptcha('login')
}
},
template: '<button @click="recaptcha">Execute recaptcha</button>'
})
Options
This plugin offers optional options to configure the behavior of some parts.
Available options:
Name | Description | Type | Default value |
---|
siteKey | The site key for your domain from Google. | string | none |
loaderOptions | Optional options for the recaptcha-v3 loader. The available options are described here. | object | null |
Usage
To use the options just pass an object to the Vue.use(...)
method. For example:
import Vue from 'vue'
import { VueReCaptcha } from 'vue-recaptcha-v3'
Vue.use(VueReCaptcha, {
siteKey: '<site key>',
loaderOptions: {
useRecaptchaNet: true
}
})
Advanced usage
Some topics which are not commonly used, but required in some cases.
In some cases it's necessary to interact with the reCAPTCHA-v3 instance, which provides more control over reCAPTCHA.
const recaptcha = this.$recaptchaInstance
recaptcha.hideBadge()
recaptcha.showBadge()