Skip to content

DanSnow/vue-recaptcha

Repository files navigation

vue-recaptcha

Greenkeeper badge devDependencies Status peerDependencies Status CircleCI npm version npm downloads

Description

Google ReCAPTCHA component for vue.

This version is for Vue 2.0. If you need Vue 1.x support please reference to vue-v1.x.

Install

NPM

$ npm install vue-recaptcha

CDN

<script src="https://unpkg.com/vue-recaptcha@latest/dist/vue-recaptcha.js"></script>
<!-- Minify -->
<script src="https://unpkg.com/vue-recaptcha@latest/dist/vue-recaptcha.min.js"></script>

Usage

General

Place this in head to load reCAPTCHA:

<script src="https://www.google.com/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit" async defer>
</script>
With `onload` callback, it will notify us when the api is ready for use.

Normal ReCAPTCHA

<template>
  <vue-recaptcha sitekey="Your key here"></vue-recaptcha>
</template>

<script>
  import VueRecaptcha from 'vue-recaptcha';
  export default {
    ...
    components: { VueRecaptcha }
  };
</script>

Bind Challenge to Button

<template>
  <vue-recaptcha sitekey="Your key here">
    <button>Click me</button>
  </vue-recaptcha>
</template>

<script>
  import VueRecaptcha from 'vue-recaptcha';
  export default {
    ...
    components: { VueRecaptcha }
  };
</script>

Notice: You could only place one element as vue-recaptcha child.

For more information, please reference to example

API

Props

  • sitekey (required)
    ReCAPTCHA site key
  • theme (optional)
    The color theme for reCAPTCHA
  • type (optional)
    The type of reCAPTCHA
  • size (optional)
    The size of reCAPTCHA
  • tabindex (optional)
    The tabindex of reCAPTCHA
  • badge (optional) (Invisible ReCAPTCHA only)
    Position of the reCAPTCHA badge

For more information, please reference to ReCAPTCHA document and Invisible ReCAPTCHA document.

Methods

  • reset
    Reset reCAPTCHA instance
  • execute
    Invoke reCAPTCHA challenge

Events

  • recaptchaReset Reset ReCAPTCHA instance