npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-recaptcha-notin

v2.0.2

Published

ReCAPTCHA vue component

Downloads

2

Readme

vue-recaptcha

devDependencies Status peerDependencies Status CircleCI npm version npm downloads

Description

Notice: The document on github is always reference to master branch. For stable version, please read the document at NPM.

Google ReCAPTCHA component for vue. If you like this package, please leave a star on github.

This version is for Vue 3 and 2.

reCAPTCHA V3

Notice: This project currently not supporting reCAPTCHA v3.

Install

NPM

$ npm install --save vue-recaptcha

Yarn

$ yarn add vue-recaptcha

CDN

<!-- Make sure you load the vue-demi first -->
<script src="https://unpkg.com/[email protected]/lib/index.iife.js"></script>

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

Usage

Get started

Include vue-recaptcha in your app.

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

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

Manually call challenge

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

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

    methods: {
      onEvent() {
        // when you need a reCAPTCHA challenge
        this.$refs.recaptcha.execute();
      }
    }
  };
</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
  • loadRecaptchaScript (optional) – If loadRecaptchaScript when set this to true, vue-recaptcha will inject the required <script> tag automatically. Disable this by setting this to false, and you need to inject the <script> tag manually. Please refer to Manually load script for more information. Default: true

The following props will only work when loadRecaptchaScript is set as true

  • recaptchaHost (optional) – Set this to change the reCAPTCHA domain if neccessary, as described in ReCAPTCHA support Default: www.google.com
  • recaptchaScriptId (optional) – Set this to change the injected <script> id. This should only be changed if it conflicts with existing id Default: __RECAPTCHA_SCRIPT
  • language (optional) – Set this to change the reCAPTCHA language if necessary, as described in ReCAPTCHA support Default: '' // user browser language by default
    Notice: It'll not work as you expecting when you change this props dynamically. Since it's impossible to change the language without a full page reloading

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

Methods

  • reset – Reset reCAPTCHA instance
  • execute – Invoke reCAPTCHA challenge

Events

  • verify(response) – Emit on reCAPTCHA verified response is the successful reCAPTCHA response

  • expired() – Emit on reCAPTCHA expired

  • render(id) – Emit on reCAPTCHA mounted on DOM id is the widget id of the component

  • error() – Emit when reCAPTCHA encounters an error

    <vue-recaptcha
      :siteKey="siteKey"
      @verify="verifyMethod"
      @expired="expiredMethod"
      @render="renderMethod"
      @error="errorMethod">
    </vue-recaptcha>

FAQ

What is "ReCAPTCHA couldn't find user-provided function: vueRecaptchaApiLoaded"?

It's because google's recaptcha have been loaded before your app. You can simply ignore it because vue-recaptcha can still detect and render recaptcha. If you care about this, try to move the script tag of recatpcha after to your app.

How to test vue-recaptcha?

You can mock window.grecaptcha to bypass google's recaptcha. Here is an example which work with jest.

How about an e2e testing (or integration testing)?

Please reference to recaptcha's FAQ.

Manually load <script>

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.