This site uses react-google-recaptcha to render the reCAPTCHA widget.
To make the reCAPTCHA work, youāll need to do the following:
- Sign up for a reCAPTCHA API key pair for your site.
- Log in to your Netlify account, and add the following environment variables to your siteās Settings > Build & deploy > Build environment variables:
SITE_RECAPTCHA_KEY
with your reCAPTCHA site key.SITE_RECAPTCHA_SECRET
with your reCAPTCHA secret key.
- Change the build command for your site to
echo -e "GATSBY_SITE_RECAPTCHA_KEY=$SITE_RECAPTCHA_KEY\nGATSBY_SITE_RECAPTCHA_SECRET=$SITE_RECAPTCHA_SECRET" >> .env.production && gatsby build
Note: Thereās probably a more elegant way to make the SITE_RECAPTCHA_KEY
environment variable available to Gatsby in production. This was just the quickest way I found to make it work without having to duplicate the variable
To see the reCAPTCHA widget locally, add GATSBY_SITE_RECAPTCHA_KEY=your-reCAPTCHA-API-site-key
to your local .env.development file.