• ShipSaaSDocumentation
  • Introduction
  • Getting Started
    • Installation
    • Environment Setup
    • Database Setup
    • Development Guide
  • Database
    • Repository Pattern
    • Drizzle Queries
    • Migration Workflow
    • Drizzle Studio
    • Best Practices
  • File Management
    • File Upload Component
    • Server Actions
    • Storage Configuration
  • Authentication Methods
    • Credentials Authentication
    • Magic Link Authentication
    • Two-Factor Authentication (2FA)
    • Social Authentication
    • API Keys & Bearer Tokens
    • Organizations (Multi-tenant)
  • Authorization & Permissions
    • Roles & Hierarchy
    • Route Protection
    • API Protection
    • CASL Permissions
  • Email & Notifications
    • Resend Setup
    • React Email Templates
    • Notification System
    • Email Workflows
    • Customization & Extension
  • Stripe & Payments
    • Stripe Setup
    • Better Auth Integration
    • Checkout Methods
    • Subscription Management
    • Admin Dashboard
    • Webhook Events
  • Architecture & Development
    • Presentation Layer
    • Service Layer
    • Persistence Layer
    • Helpers Architecture
    • Project Structure
    • Development Workflow
  • Testing
    • General Testing
    • Unit Testing
    • UI Component Testing
    • Repository Testing
    • Service Testing
    • End-to-End Testing
  • Deployment
    • Vercel Deployment
    • GitHub Actions CI/CD
    • Database Backup & Restore
    • Database Migrations
    • Troubleshooting Deployment
  • AI Agents Integration
  • Blog Management
    • Blog Setup
    • MDX Blog
    • Database Blog
  • Async Tasks
    • Setup
    • Email Workflows
    • Payment Processing
    • Maintenance Jobs
  1. Documentation
  2. Email & Notifications
  3. Resend Setup
Buydocschangelogsdemocommunity

Resend Setup

PreviousEmail & NotificationsNextReact Email Templates
On this page
Resend Account SetupEmail Service ConfigurationCore Email ServiceSimple Email FunctionAvailable Email FunctionsEnvironment VariablesError HandlingTesting Email Delivery

The boilerplate uses Resend as the email service provider, offering reliable transactional email delivery with excellent developer experience.

Perfect for: Transactional emails, authentication flows, notifications, and professional email delivery.

Resend Account Setup

1

Create Resend Account

  1. Go to resend.com and create an account
  2. Verify your email address
  3. Add your domain for production use
2

Get API Key

  1. Navigate to the API Keys section
  2. Create a new API key
  3. Copy the API key for environment configuration
3

Configure Environment

Add the required environment variables to your .env.local:

bash
# Resend Configuration
RESEND_API_KEY="re_your_api_key_here"
EMAIL_FROM="noreply@yourdomain.com"

# For development, you can use the default
EMAIL_FROM="onboarding@resend.dev"

Email Service Configuration

The boilerplate provides a configured email service in src/services/email-service.ts:

Core Email Service

typescript
// From src/services/email-service.ts
import { Resend } from 'resend'
import { env } from '@/env'

const resend = new Resend(env.RESEND_API_KEY)

export const sendEmailService = async (
  payload: CreateEmailOptions,
  options?: CreateEmailRequestOptions
) => {
  if (env.NODE_ENV === 'development') {
    payload.subject = `[DEV] ${payload.subject}`
  }

  const { error } = await resend.emails.send(
    {
      ...payload,
      from: env.EMAIL_FROM ?? 'onboarding@resend.dev',
    },
    options
  )

  if (error) {
    console.error(error)
    throw error
  }
}

Development Mode: In development, all email subjects are automatically prefixed with [DEV] to distinguish them from production emails.

Simple Email Function

For basic text emails, use the sendSimpleEmailService:

typescript
// From src/services/email-service.ts
export const sendSimpleEmailService = async ({
  to,
  subject,
  text,
}: {
  to: string
  subject: string
  text: string
}) => {
  await sendEmailService({
    to,
    subject,
    text,
    from: env.EMAIL_FROM ?? 'onboarding@resend.dev',
  })
}

Available Email Functions

The boilerplate includes 13 specialized email functions:

typescript
// Magic link authentication
sendMagicLinkEmailService({ email, url })

// Email verification
sendVerificationEmailService({ email, url })

// Password reset
sendResetPasswordLinkEmailService({ email, url })

// OTP codes
sendOTPEmailService({ email, otp, otpLink })

// Email change verification
sendEmailChangeEmailVerificationService({ email, url })
typescript
// Subscription completed
sendSubscriptionCompletedEmailService(subscription)

// Subscription updated
sendSubscriptionUpdatedEmailService(subscription)

// Subscription canceled
sendSubscriptionCanceledEmailService(subscription)

// Subscription deleted
sendSubscriptionDeletedEmailService(subscription)
typescript
// Organization invitation
sendOrganizationInvitation({
  email,
  invitedByUsername,
  invitedByEmail,
  teamName,
  inviteLink,
})
typescript
// Generic notifications
sendNotificationEmailService({
  email,
  title,
  message,
  type: 'info' | 'warning' | 'success' | 'error',
  language: 'fr' | 'en' | 'es',
})

// Welcome follow-up
sendWelcomeFollowUpEmailService({
  email,
  userName,
  appUrl,
  language,
})

Environment Variables

Required: Make sure these environment variables are set in your deployment environment.

bash
# Required
RESEND_API_KEY="your-resend-api-key"

# Recommended (defaults to onboarding@resend.dev)
EMAIL_FROM="noreply@yourdomain.com"

# Used in email templates
NEXT_PUBLIC_APP_URL="https://yourdomain.com"

Error Handling

The email service includes built-in error handling:

typescript
// From src/services/email-service.ts
const { error } = await resend.emails.send(emailData)

if (error) {
  console.error(error)
  throw error
}

Errors are logged and thrown, allowing the calling code to handle them appropriately.

Testing Email Delivery

1

Development Testing

  • All emails in development are prefixed with [DEV]
  • Check your console for email sending logs
  • Use Resend dashboard to monitor delivery
2

Domain Verification

  • For production, verify your domain in Resend
  • Update EMAIL_FROM to use your verified domain
  • Test with your production domain
3

Monitor Delivery

  • Use Resend dashboard for delivery analytics
  • Monitor bounce rates and delivery success
  • Check spam folder if emails aren't received

Resend configured! Your application can now send professional transactional emails with reliable delivery and excellent analytics.