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
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
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 | |
| 0.0.9 | ^3.4.19 | MIT | |
| 0.0.8 | ^3.4.19 | MIT | |
| 0.0.7 | ^3.4.19 | MIT | |
| 0.0.6 | ^3.4.19 | MIT | |
| 0.0.5 | ^3.4.19 | MIT | |
| 0.0.4 | ^3.4.19 | MIT | |
| 0.0.3 | ^3.4.19 | MIT | |
| 0.0.2 | ^3.4.19 | MIT | |
| 0.0.1 | ^3.4.19 | MIT |