Setup & Configuration
Learn how to set up Resend in Plainform by configuring environment variables, initializing the client, and setting up DNS for email deliverability. It details the steps to obtain API keys and configure your domain.
To use Resend, you must configure the RESEND_API_KEY and RESEND_AUDIENCE_ID in your .env file, validated by t3-env, and set up DNS records for reliable email delivery. The Resend client is initialized in lib/resend to enable email sending and audience management.
Steps to Set Up Resend
Create a Resend Account
- Sign up at Resend and create a new account.
- Access the Resend dashboard to obtain API keys and audience settings.
Obtain Resend API Key and Audience ID
- Navigate to API Keys in the Resend dashboard and generate a key.
- Create an audience in Audiences for newsletter subscribers and copy the Audience ID.
Configure Environment Variables
- Add these to your
.env(or.env.local) file:
| Env Variable | Type | Default |
|---|---|---|
RESEND_API_KEY | string | re_xxxx |
RESEND_AUDIENCE_ID | string | - |
- Ensure
.envis in.gitignoreto protect sensitive keys.
Set Up DNS for Email Deliverability
- In the Resend dashboard, go to Domains and add your domain (e.g.,
yourapp.com). - Copy the provided DNS records (e.g., DKIM, SPF, DMARC) and add them to your domain registrar (e.g., Namecheap, GoDaddy).
- Verify the domain in Resend to ensure emails avoid spam folders.
Initialize the Resend Client
- Plainform Dev includes the Resend client in
lib/resend/resend.ts:
import { Resend } from 'resend';
export const resend = new Resend(process.env.RESEND_API_KEY);Verify Configuration
- Run
npm run devto validate environment variables viat3-env(inenv.mjs). - If validation fails, check your API key and audience ID in the Resend dashboard.
For advanced configurations, such as bucket policies or CORS settings, consult the Resend Documentation.
How is this guide ?
Last updated on
Overview
Learn Resend’s role in Plainform, detailing its reliable email features for transactional and marketing purposes.
Usage & Integration
Learn how to use Resend to send transactional emails, manage newsletter subscriptions, and handle webhooks, integrated with Prisma. It includes code snippets for common tasks, adaptable to your project’s needs.