This starter contains Netlify forms examples and reCAPTCHA with the main Gatsby configuration files you might need to run your contact form page.
Below you will find instructions for each step.
Clone this repository
Download ZIP or:
git clone https://github.com/RafalMCichon/gatsby-netlify-form-examples.git
or:
Clone and deploy with a click
Installation
Install dependencies.
yarn
.env
files at the top-level (root).env.development
.env.production
.
βββ node_modules
βββ src
βββ .env.development
βββ .env.production
βββ .gitattributes
βββ .gitignore
βββ .prettierignore
βββ .prettierrc
βββ gatsby-browser.js
βββ gatsby-config.js
βββ gatsby-node.js
βββ gatsby-ssr.js
βββ LICENSE
βββ package.json
βββ README.md
βββ yarn.lock
https://www.google.com/recaptcha/intro/v3.html
Admin console
Click +
button to create new key
Label
your website domain or project name
reCAPTCHA type
reCAPTCHA v2
"I'm not a robot" tickbox (checkbox)
Domains
your-domain
site-name.netlify.com
(for netlify test)localhost
(for development)βοΈ Accept the reCAPTCHA Terms of Service (checkbox)
Submit
COPY SITE KEY
and paste in your .env
files:
GATSBY_SITE_RECAPTCHA_KEY = your_site_key
COPY SECRET KEY
and paste in your .env
files:
GATSBY_SITE_RECAPTCHA_SECRET = your_secret_key
Go to analytics
Navigate into your new siteβs directory and start it up:
gatsby develop
New site from Git
and Deploy site
Open Site settings
and Change site name
to your github project name
this name is needed in the reCAPTCHA Domains
configuration
Open Build & deploy
/ Environment
/ Edit variables
Set the key and secret in your siteβs build environment variables.
Use GATSBY_SITE_RECAPTCHA_KEY
to set your site key
, and GATSBY_SITE_RECAPTCHA_SECRET
to set the secret value
provided by reCAPTCHA 2 - more details here.
remember to add a prefix **`GATABY`**_
(unlike in netlify documentation)
Open Deploys
/ Trigger deploys
and Clear cache and deploy site
Go to Forms and check if they are all visible there - if not make sure they have unique names.
Netlify Recaptcha: If youβre using the:
<form data-netlify-recaptcha="true"></form>
element to add our recaptcha, you can only have one form using this. If you create multiple forms, receiving submissions will not work.
Choose Email notification.
your-email
Choose Form
And Save !
we are ready to test if everything works
Netlify Form
#header h1 a {
display: block;
width: 300px;
height: 80px;
}
<div hidden>
<label>
Donβt fill this out if you're human:
<input name="bot-field" onChange={this.handleChange} />
</label>
</div>