JavaScript for WordPress Forums Bugs & Issues Gatsby Contact Form Handler

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #119268


    I am curious how others might add a form handler for a contact form set up in a Gatsby src/pages or src/components directory. I can see Netlify or Formspree are popular solutions where a url is passed in the form action. I don’t want to get in the habit of using those resources (Netlify/Formspree), I have my reasons. I prefer to use server side resources. For now, I manually add a form-handler.php to the /public directory and then send that via SSH to the document root on the server. It works, but I’m dubious about my method and looking for reassurance? What would you recommend? Thanks for any direction. I sincerely appreciate it.

    Zac Gordon

    I looked at both Netlify and Formspree for the Gatstby Basics Course.

    Netlify looks good but you have to use their servers and doesn’t currently really work locally. Formspree is a bit easier to test, but not a fan of some of the features.

    I’m going to be showing how to do this with WordPress and native WordPress form plugins in my Gatsby and WordPress course.

    However, if you want to do this completely on your own this might help you setup something simple:

    Integrating with something like Sendgrid might be a better solution.

    You’ll want to make sure your hosting for the Gatsby site can run a PHP form handler, and in general switching to a JS driven one might be a better match overall.

    Hope that helps a bit!


    Thanks Zac. For now I added form-handler.php to a /static directory. Given that files in the /static directory are compiled into the /public root, it was a good solution for the time being. The form-action posts to the form-handler.php and all works great. I am interested is doing this in a way that is more along the lines of what “should” be protocol for react.js. But then, I’m constantly adapting.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.