GithubHelp home page GithubHelp logo

gatsby-netlify-form-example-v2's Introduction

Integrating Netlify Form Handling in Gatsby

Example for integrating a basic contact form with Netlify’s form handling feature.

Demo: https://gatsby-netlify-form-example-v2.netlify.com/

Note: You can also find a Gatsby + Netlify Forms example in the Gatsby+NetlifyCMS starter.

Features:

  • Basic form submission
  • File upload
  • Form submission with reCAPTCHA

All examples use controlled forms to offer more flexibility, but you can use uncontrolled forms too.

More information in the blogpost: https://www.netlify.com/blog/2017/07/20/how-to-integrate-netlifys-form-handling-in-a-react-app/

Deploy

Deploy to Netlify

Try it out in Gitpod

Open in Gitpod

reCAPTCHA

This example site uses react-google-recaptcha to render the reCAPTCHA widget.

To make the reCAPTCHA example work in your own copy of this site, you’ll need to do the following:

  1. Sign up for a reCAPTCHA API key pair for your site.
  2. 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.

Important: the environment variables need to be called SITE_RECAPTCHA_KEY and SITE_RECAPTCHA_SECRET for the Netlify backend to find them. If you add a GATSBY_ prefix to the variable names, the Netlify backend won't recognize them, the reCAPTCHA verification will fail, and your form submissions won't be stored.

  1. Change the build command for your site to
echo SITE_RECAPTCHA_KEY=$SITE_RECAPTCHA_KEY >> .env.production && gatsby build

This will make the SITE_RECAPTCHA_KEY available to the Gatsby build in production.

To see the reCAPTCHA widget locally, add SITE_RECAPTCHA_KEY=your-reCAPTCHA-API-site-key to your local .env.development file.

gatsby-netlify-form-example-v2's People

Contributors

bdougie avatar d2s avatar dependabot[bot] avatar emilyaviva avatar fritz-c avatar gesposito avatar imorente avatar kyleamathews avatar levibuzolic avatar mef avatar patrykkopycinski avatar rclai avatar slightlytyler avatar stefvhuynh avatar svenefftinge avatar svenjungnickel avatar swyxio avatar the-zebulan avatar timurc avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.