I'm implementing recaptcha in my webapp in some forms.
I already implement my backend part and i'm right now trying to install recapatcha api.
Unfornatly, I do not find an official package in npm from google.
Should I use the package googleapis that include recpatcha or should I include this script :
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
I'm asking this because I build my script files ( including all vendors coming from npm ) with Webpack.
You can just use google reCAPTCHA v3 without any npm hassle.
Register from here : https://www.google.com/recaptcha/admin/create
Then for front-end:
<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>
<script>
grecaptcha.ready(function() {
grecaptcha.execute('reCAPTCHA_site_key', {action: 'homepage'}).then(function(token) {
...
});
});
</script>
In v3 you can define your actions or pass your intent
<script>
grecaptcha.ready(function() {
grecaptcha.execute('reCAPTCHA_site_key', {action: 'homepage'});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With