0.0.14 • Published 3 months ago

v3-recaptcha v0.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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

VariablesTypeDescription
recaptchaIsLoadedrefReturns whether the recaptcha script has loaded.
hasRecaptchacomputedReturns whether the site key has been loaded
loadRecaptchafunctionLoads the recaptcha script, will be skipped if site key is null OR is already loaded
getTokenasync functionReturns either a string if site key is set, or undefined if site key is null
0.0.11

3 months ago

0.0.12

3 months ago

0.0.13

3 months ago

0.0.14

3 months ago

0.0.10

3 months ago

0.0.9

3 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.5

3 months ago

0.0.4

3 months ago

0.0.3

3 months ago

0.0.2

3 months ago

0.0.1

3 months ago