Deploying React Forms Using Formspree with ZEIT Now

Create and deploy a React form with the help of Formspree and ZEIT Now.

Formspree is a form backend that sends submissions via email which can connect to several third-party services such as Google Sheets, MailChimp, Slack, and more. Formspree also provides spam mitigation and filtering, file upload, automatic responses, and other tools to help you manage your forms.

In this guide, you will discover how to create a "contact us" form using React, similar to the example app, handle the form submission with Formspree and deploy it with ZEIT Now.

Step 1: Creating a New Formspree form

Get started integrating Formspree with ZEIT Now by using the Create a Form with ZEIT Now page. Add the email you would like to receive form submissions at and create your form.

The Create a Form with ZEIT Now page on Formspree.

Formspree will first ask you to provide a password, then you will be redirected to an integration page where you can get your form URL.

Make a note of your form's endpoint. This will be used later to submit the form you build.

Go to your form's Settings to find the reCAPTCHA setting and toggle it off. To use AJAX on Formspree you must either disable reCAPTCHA or provide your own reCAPTCHA key.

Note: You can find more information on using reCAPTCHA with AJAX in the Formspree documentation.

The Settings page on Formspree.

Step 2: Building Your Form

Create a React app from your terminal with Create React App:

npm init react-app my-formspree-app && cd my-formspree-app

Creating and entering into a React app.

Add the axios dependency to your project:

npm install axios

Adding the axios dependency to the project.

Create a ContactForm.js file in the /src directory with the code below:

import React, { useState } from 'react'
import axios from 'axios'

export default () => {
  const [status, setStatus] = useState({
    submitted: false,
    submitting: false,
    info: { error: false, msg: null }
  const [inputs, setInputs] = useState({
    email: '',
    message: ''
  const handleServerResponse = (ok, msg) => {
    if (ok) {
        submitted: true,
        submitting: false,
        info: { error: false, msg: msg }
        email: '',
        message: ''
    } else {
        info: { error: true, msg: msg }
  const handleOnChange = e => {
    setInputs(prev => ({
      submitted: false,
      submitting: false,
      info: { error: false, msg: null }
  const handleOnSubmit = e => {
    setStatus(prevStatus => ({ ...prevStatus, submitting: true }))
      method: 'POST',
      url: '[your-formspree-endpoint]',
      data: inputs
      .then(response => {
          'Thank you, your message has been submitted.'
      .catch(error => {
  return (
      <h1>React and Formspree</h1>
      <hr />
      <form onSubmit={handleOnSubmit}>
        <label htmlFor="email">Email</label>
        <label htmlFor="message">Message</label>
        <button type="submit" disabled={status.submitting}>
            ? !status.submitted
              ? 'Submit'
              : 'Submitted'
            : 'Submitting...'}
      { && (
        <div className="error">Error: {}</div>
      {! && && <p>{}</p>}

Adding a ContactForm.js file to the project.

This form takes two inputs, the user email and message, using axios to make the POST request with the submission data to the Formspree endpoint received earlier on.

Note: Make sure to replace your-formspree-endpoint with the endpoint received in Step 1.

Now you just need to use the form in your app. Change the contents of the App.js file to the following:

import React from 'react'
import ContactForm from './ContactForm'

export default function App() {
  return (
      <ContactForm />

Using the ContactForm component in the App.js file.

Note: If you wish to use the same styles as our example app, you can find them here.

Step 3: Deploy With ZEIT Now

You can choose whether you want to deploy directly from the command line with Now CLI, or from a Git repository by installing either the Now for GitHub or Now for GitLab integrations.

To deploy your project using Now CLI, all it takes is a single command:


Deploying your project with the now command.

That’s it! Your form is now live and deployed to a publicly accessible url immediately. If you have used the styles provided, it will look similar to the example app.

Form submissions received from either your localhost or production environments will be emailed, and show up in your form submissions list. If you want to restrict where the form can be embedded, set your production URL in the authorized domains setting in Formspree.

Bonus: Special Formspree Names

Formspree allows you to provide specially named inputs to control how form submissions are processed.

Below is a list some of the most commonly used values, but you can find all of them in the Form Setup section of the Formspree help guide.


Use this name to set the Reply-To email address of the submission notification emails.

This allows you to quickly reply to form submissions in your inbox and is shown in the example below.

<input type="email" name="_replyto" placeholder="your email address">

An example input element that uses the name="_subject" attribute to set the Reply-To of the email.


Use this name to set the subject of notification emails. This will override the default New submission from … subject.

Note: You should place this in a hidden input as done in the example below.
<input type="hidden" name="_subject" value="New lead on">

An example input element that uses the name="_subject" attribute to set the subject of the email.

Written By
Written by msweeneydevmsweeneydev
on September 12th 2019