Introduction
When using Crunchforms, you may want to switch between different form IDs (for example, staging vs production forms) and manage environment-specific configuration. This page describes best practices for:- Defining and using multiple form IDs
- Using environment variables to manage differences between environments
- Example setups for popular stacks (Node.js, Next.js, etc.)
Why Use Environment Variables
Hard-coding yourformID in your source code can cause the Wrong form being used in production or inefficiencies switching contexts (dev ←→ staging ←→ prod)
Using environment variables lets you:
- Keep environment-specific values outside your codebase
- Use the same code to support multiple environments
- Reduce risk of mixing up IDs or endpoints
Recommended Variable Structure
Here’s a suggested set of environment variables for form usage:Setting Up for Multiple Environments
1. Environment Variable Files
Here’s how you might structure.env (for local development) and CI/CD environment variables:
.env.development
.env.staging
.env.production
2. Code Sample
config/crunchforms.js
Next steps
Explore advanced configurations and features:Set up a Honeypot Field
Get easy protection agains simple bots using a hidden field
Set up Cloudflare Turnstile
Advanced bot protectionion using Cloudflare Turnstile
Use Environments
Explore advanced methods using eviromenents to manage build, test, and protection forms
Add additional email addresses
Add and verify additional email addresses to receive form submission notifications
Need Help?
Get Support
Send us a note