Giter VIP home page Giter VIP logo

vue3-recaptcha-v2's Introduction

vue3-recaptcha-v2

GitHub package.json version npm bundle size NPM

reCAPTCHA v2 for Vue3 : CompositionAPI, Types

If you use v0.x, recommend using v1.x or higher.

Installation

Yarn

$ yarn add vue3-recaptcha-v2

npm

$ npm install vue3-recaptcha-v2 --save

Example

Setup

// main.js
import { createApp } from "vue";
import App from "./App.vue";
import VueRecaptcha from "vue3-recaptcha-v2";

const app = createApp(App);

app
  .use(VueRecaptcha, {
    siteKey: "your recaptcha sitekey",
    alterDomain: false, // default: false
  })
  .mount("#app");

*install options

Option Type Description
siteKey string (required) recaptcha siteKey
alterDomain boolean true: domain replace www.google.com with www.recaptcha.net

Usage

<template>
  <vue-recaptcha
    theme="light"
    size="normal"
    :tabindex="0"
    @widgetId="recaptchaWidget = $event"
    @verify="callbackVerify($event)"
    @expired="callbackExpired()"
    @fail="callbackFail()"
  />

  <button @click="actionReset()">reset!</button>
</template>

<script>
  import { ref } from "vue";
  import { VueRecaptcha, useRecaptcha } from "vue3-recaptcha-v2";

  export default {
    name: "recaptcha",
    components: { VueRecaptcha },
    setup: () => {
      // Reset Recaptcha
      const { resetRecaptcha } = useRecaptcha();
      const recaptchaWidget = ref(null);

      const callbackVerify = (response) => {
        console.log(response);
      };
      const callbackExpired = () => {
        console.log("expired!");
      };
      const callbackFail = () => {
        console.log("fail");
      };
      // Reset Recaptcha action
      const actionReset = () => {
        resetRecaptcha(recaptchaWidget.value);
      };

      return {
        recaptchaWidget,
        callbackVerify,
        callbackFail,
        actionReset,
      };
    },
  };
</script>

API

Props

vue-recaptcha components props list

theme

  • optional
  • type : light | dark
  • default : light

size

  • optional
  • type : normal | compact | invisible
  • default : normal

tabindex

  • optional
  • type : number
  • default : 0

Emit

vue-recaptcha components emit list

widgetId

  • return : number

verify

  • return : string

expired

  • return : void

fail

  • return : void

methods

vue-recaptcha components methods list

resetRecaptcha

  • param : widgetId
  • return : void

vue3-recaptcha-v2's People

Contributors

dongkyuuuu avatar viper-vlad avatar imshara avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.