v3-recaptcha

Easily incorporate V3 recaptcha from google into your application
1,176 1
Install
npm install v3-recaptcha
Latest Version:0.0.14
Vue:3
License:MIT
Last Updated:Feb 19, 2024
Links: GitHub  ·  npm
Maintainer: bored-lunatic

V3 Recaptcha for Vue3

Version Badge License Badge Made By

About

This package is used to incorporate Googles V3 Recaptcha into a vue project easily. It handles:

  • Injecting script into head to load googles recaptcha.
  • Generating a token to be verified on your server.
  • Pass actions to recaptcha token generator
  • Handle recaptcha loading dynamically if required.

Installation

npm install v3-recaptcha

Usage

Import the package in the component you want to use recaptcha.

import { useV3Recaptcha } from "v3-recaptcha";

Pull the required functions:

const { recaptchaIsLoaded, hasRecaptcha, loadRecaptcha, getToken } = useV3Recaptcha("YOUR SITE KEY HERE");

"YOUR SITE KEY HERE" should be replaced with your site key from google. If you are adding this into a package and allowing users choose if they want to include recaptcha, this can be replaced with null and recaptcha wont load, getToken will then return undefined instead of a token string.

Load recaptcha is typically best to add this on the onMounted hook:

onMounted(() => {
  loadRecaptcha();
});

Get a token:

const token = await getToken(`process_form`);

Functions and Variables

Variables Type Description
recaptchaIsLoaded ref Returns whether the recaptcha script has loaded.
hasRecaptcha computed Returns whether the site key has been loaded
loadRecaptcha function Loads the recaptcha script, will be skipped if site key is null OR is already loaded
getToken async function Returns either a string if site key is set, or undefined if site key is null

Related Packages

@enso-ui/google

Google integration settings pages for Enso UI

8,808 0
lighthouse-stack-packs

Lighthouse Stack Packs

142,086,521 219
vue-google-autocomplete

Vue component to Google Places Autocomplete

1,307,599 502
vue-google-pay

Google Pay component for Vue

10,473 6
vue-google-signin-button-directive

A simple Vue directive to include Google Sign-In Button behavior in any componen...

7,444 43

Version History

Version Released Vue License
0.0.14 ^3.4.19 MIT
0.0.13 ^3.4.19 MIT
0.0.12 ^3.4.19 MIT
0.0.11 ^3.4.19 MIT
0.0.10 ^3.4.19 MIT