Integration with Resend
Learn how to integrate Resend with your Lovable application
What is Resend
Resend is an email API built for developers. It focuses on high deliverability, ease of integration, and a clean developer experience for sending transactional and marketing emails.
Step-by-step tutorial
This tutorial walks you through building a fully functional CRM in under an hour—complete with lead collection, email confirmation, newsletter subscription, and an internal admin dashboard. You’ll use:
- Lovable: to generate the front end and backend logic.
- Supabase: for secure data storage and authentication.
- Resend: to automate and track transactional + marketing emails.
Let’s get started.
Create a Landing Page with a Contact Form
Use Lovable’s AI to quickly generate a landing page for your product or service.
Instructions:
New Lovable Project
Create a new Lovable project.
Prompt:
Create a SaaS landing page with a contact form collecting name, email, and message.
Inspect the generated code
Inspect the generated code or use the select tool to tweak elements.
Add input validation
Add input validation and a message
field for better user experience.
Store Form Submissions in Supabase
Supabase acts as your secure backend database.
Supabase account
Create a free Supabase account and a new project.
API Key
In Lovable, connect your Supabase project using the API key.
Create a `contacts` table with:
id
: UUID, primary keyname
: textemail
: textmessage
: textcreated_at
: timestamp
Submission logic
Modify the form submission logic to insert data into Supabase.
RLS
Apply Supabase Row-Level Security (RLS) to restrict access to only authenticated users.
Send Confirmation Emails via Resend
Set up Resend to send automated confirmation emails every time a lead submits the form.
Sign up at Resend
Sign up at Resend and verify your custom domain.
- You’ll be asked to update your DNS records (TXT, MX).
- Use subdomains like
updates.domain.com
to manage email reputation better.
API Key
Integrate the API key in Lovable via environment settings or backend function.
SDK
Use Resend’s SDK to send a confirmation email on form submission.
Optional: React Email
Use React Email (also by Resend) to customize the look and feel of your emails with reusable components.
Build a Secure Admin Dashboard
Allow only authenticated users to view and manage leads.
Admin route
Create an /admin
route in Lovable.
Supabase Authentication
Enable Supabase authentication with email/password login.
Contacts
Display the contacts
table with columns:
- Name
- Message preview
- Submission date
Full contact detail
Add a detail pane (e.g., a sliding panel) showing full contact details when a row is clicked.
Redirect logic
Add redirect logic so unauthenticated users are routed to /login
.
Enable Custom Email Replies from Admin
Allow your team to send personalized follow-ups.
Contact detail pane
In the contact detail pane, add a text field and predefined templates (e.g., “Thanks for signing up!”).
Add send button
Add a send button wired to Resend.
Store sent messages
Store each sent message in a sent_emails
table in Supabase:
contact_id
subject
body
sent_at
This gives you a searchable log of all follow-ups.
Add a Newsletter Subscription Form
Use Resend’s Audiences to manage subscribers and send broadcast emails.
Add new form
Add a new form on your landing page for newsletter signup.
Resend contact
When submitted:
- Create a Resend contact via the API
- (Optional) Store the contact locally in Supabase as well
Design
Use Resend’s broadcast email UI to design and send newsletters.
- Built-in unsubscribe logic
- Performance insights (open rates, delivery status)
Compliance check!
For compliance (e.g. GDPR), consider implementing a double opt-in flow.
BONUS: Connecting Resend to Supabase Auth
Want to improve Supabase’s default email auth (which limits you to 4 emails/hour)?
Resend supabase
Authentication
Authenticate with your Supabase project.
Domain setup
Choose your domain and sender name/email.
SMTP
Resend automatically sets up SMTP and replaces Supabase’s default email system.
Customization
You can now customize auth email templates from the Supabase dashboard.
Final Touches & Best Practices
- Error Handling: Lovable might show build errors that are false positives. Always test your functionality live.
- Reverting with Supabase: If reverting code in Lovable, remember to manually delete associated Supabase policies or migrations—they’re not rolled back automatically.
- Deliverability Tips:
- Use subdomains to isolate reputation.
- Always include a plain text version of your email.
- Monitor email performance with Resend’s insights dashboard.
You're Done! 🎉
In less than an hour, you’ve built a modern CRM with:
- A landing page and contact form
- Database-powered lead storage
- Automated email confirmations
- Admin dashboard for lead management
- Custom email replies
- Newsletter broadcasts
- Auth and email verification
Want to go further?
- Add support for scheduled emails via Supabase cron jobs
- Build automation flows to trigger emails based on lead stages
- Style your UI for better brand trust and conversion
Resend Integration FAQ
Was this page helpful?