Required Variables
RESEND_API_KEY
The Resend API key is required for the contact form to send emails. Purpose: Authenticates your application with the Resend email service to send contact form submissions. Format: Must start withre_ followed by your unique API key.
Example: re_123456789abcdefghijklmnop
Getting Your Resend API Key
Create a Resend Account
Sign up for a free account at resend.com.
Verify Your Domain
To send emails from your own domain:
- Go to Domains in the Resend dashboard
- Click Add Domain
- Follow the DNS configuration instructions
- Wait for verification (usually a few minutes)
[email protected] for testing (already configured in the code).Generate API Key
- Navigate to API Keys in the Resend dashboard
- Click Create API Key
- Give it a descriptive name (e.g., “Product Builders Production”)
- Select appropriate permissions (“Sending access” is sufficient)
- Copy the generated API key
Local Development
For local development, create a.env.local file in your project root:
Example .env.local
Production Deployment
Configure environment variables in your deployment platform:Firebase App Hosting
Open Firebase Console
Navigate to your project in the Firebase Console.
Add Environment Variable
- Scroll to Environment variables
- Click Add variable
- Name:
RESEND_API_KEY - Value: Your Resend API key (starting with
re_) - Click Save
Netlify
Add Variable
- Click Add a variable
- Key:
RESEND_API_KEY - Value: Your Resend API key (starting with
re_) - Select scope: Production (and Deploy previews if desired)
- Click Create variable
Validation
The application validates theRESEND_API_KEY in src/app/actions.ts:
Validation Checks
- Presence Check: Ensures the variable exists
- Format Check: Verifies the key starts with
re_ - Runtime Check: Validates during form submission
Testing Your Configuration
After configuring your environment variables:Security Best Practices
Best Practices
- Use
.env.localfor local development (already gitignored by Next.js) - Never commit environment files to Git
- Rotate keys periodically for enhanced security
- Use different keys for development, staging, and production
- Restrict permissions in Resend to only what’s needed (sending access)
- Monitor usage in the Resend dashboard for suspicious activity
Troubleshooting
”Configuration error: The Resend API key is invalid”
Cause: The API key doesn’t start withre_
Solution: Verify you copied the entire API key from Resend, including the re_ prefix.
”Resend API key is not configured”
Cause: The environment variable is not set or not loaded Solution:- Verify the variable name is exactly
RESEND_API_KEY - For local development, ensure
.env.localexists in the project root - For production, verify the variable is set in your deployment platform
- Restart your development server or trigger a new deployment
Contact Form Returns Generic Error
Cause: API request to Resend failed Solution:- Check your Resend dashboard for error logs
- Verify your API key has sending permissions
- Ensure your domain is verified (if using custom domain)
- Check the browser console and server logs for detailed error messages