feat(newsletter): save home-page subscribers to Brevo (#43)#52
Closed
koechkevin wants to merge 3 commits into
Closed
feat(newsletter): save home-page subscribers to Brevo (#43)#52koechkevin wants to merge 3 commits into
koechkevin wants to merge 3 commits into
Conversation
The "Subscribe to receive updates" block was display-only text. Add a real signup form (first name + email) in the WhatsApp banner's 4th column, wired to a new POST /api/newsletter route handler that validates input, verifies reCAPTCHA v3 (score >= 0.7, env-gated), and adds the contact to a Brevo list (single opt-in) for campaign broadcasts. - app/api/newsletter/route.ts: validation + captcha + Brevo /v3/contacts - NewsletterForm: client form with reCAPTCHA v3, sonner toasts, pending state; friendly "already subscribed" message for existing contacts - Mount <Toaster/> on the home page - Env: BREVO_API_KEY, BREVO_LIST_ID, NEXT_PUBLIC_RECAPTCHA_SITE_KEY, RECAPTCHA_SECRET_KEY (documented in .env.example)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
koechkevin
marked this pull request as draft
July 9, 2026 12:56
koechkevin
marked this pull request as ready for review
July 10, 2026 10:22
koechkevin
marked this pull request as draft
July 10, 2026 10:22
…ribe-43 # Conflicts: # .env.example
…#43) PesaCheck provided a Mailchimp/MailerLite embed form, so the signup no longer needs a server integration. Replace the Brevo route + client with a styled native form that POSTs directly to the hosted endpoint (opens the provider's confirmation page in a new tab), keeping the embed's exact field names (EMAIL, MMERGE3/2/6) and hidden honeypot. - NewsletterForm: styled embed form (email + first/last name + organisation) - Remove app/api/newsletter (Brevo), its env vars, reCAPTCHA + home toast - Drop Brevo config from .env.example (no server config needed now)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the outstanding part of #43 — the copy change already merged in #49, but the "Subscribe to receive updates" block was display-only text with no way to actually capture subscribers (flagged in #49). This adds a real signup form wired to Brevo.
app/api/newsletter/route.ts— POST handler: validates email + first name, verifies reCAPTCHA v3 (score ≥ 0.7, only when configured), then adds the contact to a Brevo list viaPOST /v3/contacts(updateEnabled:true, single opt-in).components/home/NewsletterForm.tsx— client form (first name + email + Subscribe) added to the WhatsApp banner's 4th column, with reCAPTCHA v3, sonner toasts, and a pending state. Existing contacts get a friendly "You're already subscribed" message.<Toaster/>mounted on the home page. Addedsonnerdependency.Configuration (set in Vercel)
BREVO_API_KEYBREVO_LIST_IDNEXT_PUBLIC_RECAPTCHA_SITE_KEYRECAPTCHA_SECRET_KEYWhen the reCAPTCHA keys are absent, the form still submits (captcha skipped) — intended for local dev. Documented in
.env.example.Testing
Ran the app:
400 "Please enter a valid email address."500 "Newsletter signup is not configured."401→ route returns502, error loggedtsc --noEmitand biome lint pass. A real201success needs live Brevo keys.Design decisions
Brevo (single opt-in), email + first name, reCAPTCHA v3, Route Handler + sonner toast, friendly duplicate handling — all confirmed with the team before implementation.
Notes
sonner— a trivial overlap if both merge.Closes #43