Using StaticForms with Gatsby: Complete Integration Guide
Building a static site with Gatsby doesn't mean you have to sacrifice form functionality. StaticForms makes it easy to add contact forms and other data collection features to your Gatsby site without writing backend code or managing servers.
In this guide, we'll walk through integrating StaticForms with Gatsby, including basic setup and spam protection with reCAPTCHA or privacy-first Altcha CAPTCHA.
Why StaticForms for Gatsby?
Gatsby generates static HTML at build time with no server to process forms. StaticForms bridges this gap with:
- ✅ No Backend Required: Handle forms without servers or serverless functions
- ✅ Instant Setup: Add your API key and start receiving submissions
- ✅ Email Notifications: Get submissions delivered to your inbox
- ✅ Spam Protection: Honeypot, reCAPTCHA, and Altcha CAPTCHA options
- ✅ File Uploads: Accept attachments up to specified limits
- ✅ Webhook Integration: Connect to external services (paid plans: Pro/Advanced)
Prerequisites
- A Gatsby site (version 4.x or 5.x)
- A StaticForms account (sign up here)
- Your API key from your dashboard
Basic Contact Form
Create a contact form component in your Gatsby project:
Add the form to any page:
That's it! You now have a fully functional contact form. 🎉
Adding reCAPTCHA Protection
Install the package and get your keys from Google reCAPTCHA Admin:
Add reCAPTCHA to your form:
Learn more in our reCAPTCHA guide.
Privacy-First: Altcha CAPTCHA
For GDPR-compliant spam protection without tracking, use Altcha CAPTCHA (paid plans: Pro/Advanced):
See our Altcha implementation guide for details.
Using Environment Variables
Protect your API keys with environment variables. Create .env.development:
Use in your components:
Important: Gatsby requires the GATSBY_ prefix for browser-accessible variables.
Advanced Features
Custom Redirects
Custom Fields
Add extra data with $ prefix:
File Uploads
See our file upload tutorial for implementation details.
Troubleshooting
Not receiving emails?
- Verify your API key in your dashboard
- Check spam folder
- Confirm email verification with StaticForms
Build errors?
- Restart Gatsby dev server after adding environment variables
- Check
GATSBY_prefix on all variables - Ensure dependencies are installed
Environment variables not working?
- Variables must be in project root
- Restart server after changes
- Verify
.envfiles aren't in.gitignore
Conclusion
StaticForms provides a maintenance-free form solution for Gatsby sites. Choose from honeypot, reCAPTCHA, or privacy-focused Altcha CAPTCHA for spam protection. The free tier works great for personal projects, while Pro plans offer advanced features for larger sites.
Ready to add forms to your Gatsby site? Sign up for StaticForms and get started in minutes!
For other frameworks, check out our guides for Next.js and Nuxt.js.
Happy coding! 🚀
Related Articles
Netlify Forms vs Static Forms: Complete Comparison (2026)
Compare Netlify Forms and Static Forms features, pricing, AI Reply, and ease of use. Find the best form backend solution for your static website in 2026.
Adding Contact Forms to Static Websites Guide
Learn how to easily add fully functional contact forms to your static website without backend code using a form endpoint service.
Using StaticForms with Nuxt.js: A Complete Guide
Learn how to integrate StaticForms into your Nuxt.js applications with and without reCAPTCHA protection.