Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added next js api route based newsletter implementation #66

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

gabros20
Copy link
Collaborator

1. Environment Variables Check
We need to ensure all required env vars are set:

MAILCHIMP_API_KEY=your_api_key
MAILCHIMP_LIST_ID=your_list_id
MAILCHIMP_SERVER_PREFIX=your_server_prefix  # e.g., 'us1'
RECAPTCHA_SECRET_KEY=your_recaptcha_secret

2 .Dependencies Check
Added dependency:

npm install @mailchimp/mailchimp_marketing

3. Integration Flow
✅ Frontend:

  • Collects email
  • Validates reCAPTCHA
  • Sends both to API
  • Handles all response cases correctly
  • Proper loading states
  • Good error messaging

✅ API Route:

  • Validates reCAPTCHA token
  • Validates email format
  • Checks for existing subscribers
  • Proper error handling
  • Secure error responses

4. Mailchimp Specific
✅ Integration Code:

  • Using official SDK
  • Proper member existence check
  • Clean subscription flow
  • Error handling matches Mailchimp's API responses

5. Security
✅ Good:

  • All sensitive keys server-side only
  • reCAPTCHA validation
  • Email validation
  • No sensitive data exposure

The integration looks solid and follows Mailchimp's best practices. The only thing to test in production would be:

  1. The Mailchimp server prefix format (should be like 'us1', 'us2', etc.)
  2. The List ID format (should be like 'abc123def')
  3. The API key permissions (needs write access to the list)

Everything else is properly implemented and should work as expected in a dynamic Next.js environment.

@gabros20 gabros20 requested a review from sysrex January 28, 2025 12:54
Copy link
Collaborator

@sysrex sysrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ulgtm

@sysrex sysrex merged commit f17049e into main Jan 29, 2025
1 check failed
@sysrex sysrex deleted the feature/api-route-based-implementation-of-newsletter branch January 29, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants