This is a sample static site hosted on Netlify with Google's reCAPTCHA v2, using Netlify Functions.
Try it here!
Want a reCAPTCHA for your static site without dedicating an entire back-end? This is it.
Netlify Function written in Javascript, without dependencies.
- Hide email, phone numbers from scrapers
- Hide download links
- Special messages for humans
- Add the reCAPTCHA elements (
index.html
andmain.js
) to your page - Register for your reCAPTCHA here, using your static site host name
- Obtain your
site key
, set it asdata-site-key
attribute in the reCAPTCHA form. - Obtain your
secret key
, set it as a Netlify environment variableCAPTCHA_SECRET=...
(or hard code it ... it's a free country.) - Update your Netlify Function url (whose ending should resemble
.com/.netlify/functions/{function_name}
) - Optional: set a Netlify environment variable
SECRET_MESSAGE=..
to return a message, or bake it into your serverless function.
For verification flow: https://developers.google.com/recaptcha/docs/verify
More Netlify Function examples: https://github.com/netlify/functions