Add these environment variables to your .env.local file and Vercel environment settings:
# MailerLite API Configuration
MAILERLITE_API_KEY=your_mailerlite_api_key_here
MAILERLITE_GROUP_ID=your_group_id_here # Optional: specific list/group ID- Log in to MailerLite: Go to https://www.mailerlite.com/
- Navigate to Integrations: Go to Settings → Integrations → API
- Generate API Key: Create a new API key or use an existing one
- Copy the API Key: It should start with
Beareror be a long string
- Go to Subscribers: In your MailerLite dashboard
- Select a Group: Choose the group/list you want to add subscribers to
- Check URL: The group ID will be in the URL (e.g.,
/groups/123456) - Use the ID: Add it to your environment variables
- Add Subscriber:
POST https://api.mailerlite.com/api/v2/subscribers - Documentation: https://developers.mailerlite.com/docs/
The integration maps your existing custom fields:
Custom_Fields.Tag→fields.tagin MailerLite
After setting up the environment variables:
- Restart your development server:
npm run dev - Test subscription: Try subscribing a test email
- Check MailerLite dashboard: Verify the subscriber appears
- From SendGrid: All existing functionality preserved
- Same API interface: No changes needed in your frontend code
- Better deliverability: MailerLite often has better email deliverability
- Cost effective: Usually more affordable than SendGrid
- API Key Invalid: Make sure you copied the full API key
- Group ID Not Found: Group ID is optional, you can remove it
- Rate Limiting: MailerLite has rate limits, but they're generous
- Email Already Exists: MailerLite will update existing subscribers
"MailerLite API key not configured": AddMAILERLITE_API_KEYto environment"Failed to subscribe to MailerLite": Check API key and network connection"Email already exists": This is normal, MailerLite will update the subscriber
- Go to your Vercel dashboard
- Select your project
- Go to Settings → Environment Variables
- Add:
MAILERLITE_API_KEY= your API keyMAILERLITE_GROUP_ID= your group ID (optional)
After deployment, test with a real email to ensure everything works correctly.