Newsletter Signup
Email newsletter subscription system with full campaign platform
Newsletter Signup
The newsletter system captures visitor emails across the site and feeds them into a full campaign platform with subscriber management, A/B testing, templates, automations, and analytics.
Public Signup Component
Component: NewsletterSignup.astro
Reusable Astro component with two variants:
| Variant | Used On | Layout |
|---|---|---|
full |
Homepage | Two-column: form + preview sidebar |
compact |
Blog posts | Inline bar with form |
Props:
variant—'full'or'compact'(default:'full')source— tracking string for where the signup originated (default:'website')
API: /api/newsletter/subscribe
Method: POST
Request body:
{
"email": "user@example.com",
"source": "homepage"
}
Responses:
200 { ok: true, message: "Subscribed" }— new subscription200 { ok: true, message: "Already subscribed" }— duplicate400 { ok: false, error: "Valid email required" }— validation failure500 { ok: false, error: "Server error" }— unexpected error
Storage
Subscribers are stored in Cloudflare D1 (newsletter_subscribers table) with engagement tracking, confirmation status, and tags. Legacy KV fallback still writes to newsletter:{email} for backward compatibility.
Placement
- Homepage — Full variant after the "What brings you here?" funnel CTA section
- Blog posts (
/posts/[slug]) — Compact variant before "Back to Blog" navigation - Blog layout (
BlogPost.astro) — Compact variant after post content
Full Newsletter Platform
All "future enhancements" from the original design are now implemented:
- Email delivery via Resend integration (
src/lib/email-sender.ts) - Admin dashboard at
/admin/newsletterwith 6 tabs (Dashboard, Subscribers, Composer, Campaigns, Templates, Automations) - Campaign composer with A/B subject testing, template selector, digest auto-generator
- 10 professional templates (weekly digest, announcement, tutorial, changelog, plain, re-engagement, milestone, referral, survey)
- 3 automations (welcome email, blog publish notification, re-engagement)
- Open/click tracking via tracking pixels and link wrapping
- Analytics with open rates, click rates, top links, growth charts
- CSV import/export for subscriber management
- HMAC-SHA256 unsubscribe with one-click verification
See Newsletter Admin Documentation for the full platform reference.
Open Source Package
The core logic is extracted into @argobox/newsletter — a standalone npm package with zero framework dependencies. It provides email template building, HMAC token generation, CSV parsing, and Resend adapters. Works in Cloudflare Workers, Node 18+, Deno, and Bun.
npm install @argobox/newsletter