Domain
Domain
Section titled “Domain”The ResendDomain
resource manages email domains for sending emails through Resend. Domains must be verified via DNS records before they can be used for sending emails.
Example Usage
Section titled “Example Usage”Basic Domain Setup
Section titled “Basic Domain Setup”Create a domain with default settings:
import { ResendDomain } from "alchemy/resend";
const domain = await ResendDomain("my-domain", { name: "example.com"});
console.log(`Domain ID: ${domain.id}`);console.log(`Status: ${domain.status}`);console.log(`DNS Records to configure:`);domain.records.forEach(record => { console.log(`${record.type}: ${record.name} -> ${record.value}`);});
Domain with Custom Region
Section titled “Domain with Custom Region”Create a domain in a specific region:
const euDomain = await ResendDomain("eu-domain", { name: "mail.example.com", region: "eu-west-1", apiKey: alchemy.secret(process.env.RESEND_API_KEY)});
Using Domain for Email Sending
Section titled “Using Domain for Email Sending”Once verified, use the domain for sending emails:
const domain = await ResendDomain("verified-domain", { name: "mail.example.com"});
// Use domain in email sendingconst fromAddress = `noreply@${domain.name}`;console.log(`Send emails from: ${fromAddress}`);
Properties
Section titled “Properties”Input Properties
Section titled “Input Properties”name
(required): Domain name to add to Resendregion
(optional): Region where the domain will be used. Defaults to"us-east-1"
. Options:"us-east-1"
- United States East (default)"eu-west-1"
- Europe West (GDPR compliant)"sa-east-1"
- South America East
apiKey
(optional): API key for authentication. Falls back toRESEND_API_KEY
environment variablebaseUrl
(optional): Custom API base URL. Defaults to"https://api.resend.com"
Output Properties
Section titled “Output Properties”All input properties, plus:
id
: The unique identifier for the domainstatus
: Current verification status ("not_started"
,"pending"
,"verified"
,"failed"
)records
: Array of DNS records required for domain verification:name
: DNS record nametype
: DNS record type (TXT, MX, CNAME)value
: DNS record valuettl
: Time to live for the recordpriority
: Priority for MX recordsstatus
: Individual record verification status
created_at
: Timestamp when the domain was created
DNS Configuration
Section titled “DNS Configuration”After creating a domain, you’ll need to configure DNS records with your DNS provider:
const domain = await ResendDomain("company-domain", { name: "mail.company.com"});
// Display DNS records for configurationconsole.log("Configure these DNS records:");domain.records.forEach(record => { console.log(`Type: ${record.type}`); console.log(`Name: ${record.name}`); console.log(`Value: ${record.value}`); if (record.priority) { console.log(`Priority: ${record.priority}`); } if (record.ttl) { console.log(`TTL: ${record.ttl}`); } console.log(`Status: ${record.status}`); console.log('---');});
Regional Considerations
Section titled “Regional Considerations”Choose the appropriate region based on your audience location and compliance requirements:
- US East (us-east-1): Best for North American audiences
- EU West (eu-west-1): GDPR compliant, best for European audiences
- South America East (sa-east-1): Best for South American audiences
// GDPR compliant domain for European usersconst gdprDomain = await ResendDomain("gdpr-domain", { name: "eu.example.com", region: "eu-west-1"});
Verification Process
Section titled “Verification Process”- Create Domain: Domain is created with
pending
status - Configure DNS: Add the provided DNS records to your DNS provider
- Automatic Verification: Resend automatically checks DNS records
- Verified: Domain status changes to
verified
when all records are valid
The verification process typically takes a few minutes but can take up to 24 hours depending on DNS propagation.
Important Notes
Section titled “Important Notes”- Immutable Properties: Domain name and region cannot be changed after creation
- DNS Propagation: Allow time for DNS changes to propagate globally
- Subdomain Support: You can use subdomains (e.g.,
mail.example.com
) - Multiple Domains: You can verify multiple domains for different purposes