Resend Email Setup

How to configure Resend for transactional email and newsletter subscriptions.

Last updated:

Create a Resend account

  1. Sign up at resend.com
  2. Go to API KeysCreate API Key
  3. Name it (e.g., BloggFast Production) and give it Full access
  4. Copy the key — you can only see it once

Verify your domain

For production, verify your sending domain under Domains in the Resend dashboard. Add the DNS records Resend provides to your domain registrar. Without domain verification, emails may land in spam or be limited to Resend's sandbox.

Note

During development, you can use onboarding@resend.dev as the from address to send test emails to your own account without domain verification. Resend's free tier allows 3,000 emails/month.

Configure environment variables

.env.local
RESEND_API_KEY=re_...
RESEND_FROM_EMAIL=hello@yourdomain.com
RESEND_WEBHOOK_SECRET=whsec_...    # Optional: for webhook event handling
RESEND_AUDIENCE_ID=               # Optional: for Resend Contacts sync

Email flows in BloggFast

BloggFast uses Resend for these email flows (defined in src/lib/resend.ts):

FunctionWhen it firesTemplate
sendSubscriptionConfirmationEmailWhen a user submits the newsletter subscription formHTML with a tokenized confirmation link
sendWelcomeEmailAfter subscription is confirmed via the confirmation linkHTML welcome message
upsertSubscriberContactInResendAfter confirmation — syncs the subscriber to Resend Audiences (if RESEND_AUDIENCE_ID is set)N/A — API call only
unsubscribeContactInResendWhen a subscriber opts outN/A — removes from Resend Audience

Webhook setup (optional)

BloggFast includes a Resend webhook handler at /api/webhooks/resend (via the Svix verification library) that handles bounce and complaint events. To enable:

  1. In your Resend dashboard, go to WebhooksAdd Endpoint
  2. Set the URL to https://yourdomain.com/api/webhooks/resend
  3. Select events: email.bounced, email.complained
  4. Copy the signing secret → set as RESEND_WEBHOOK_SECRET

Webhook events automatically update subscriber statuses in the database (BOUNCED, COMPLAINED) and log to the SubscriberEvent table.

Audience sync (optional)

If you want to sync subscribers to a Resend Audience (for broadcast emails), create an audience in the Resend dashboard and add the ID to your environment:

.env.local
RESEND_AUDIENCE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

If this variable is not set, the app skips the contact sync step without errors — email sending still works normally for transactional flows.