Blogs
Jun 5, 2024
We discuss and implement 3 solutions for including email notifications in your Supabase project using NodeJS.
While Supabase has a built-in email functionality, but only for authentication emails and only at a limited rate limit. There are several 3rd-party solutions to send email notifications from Supabase using Edge Functions. We will cover 3 of them using NodeJS:
NotificationAPI: 10k free emails, built-in email editor
SendGrid: 3k free emails
Resend: 3k free emails
If you are not familiar with Edge Functions, you can follow our step-by-step email + edge function guide here.
If you are familiar with Edge Functions, continue reading:
NotificationAPI
NotificationAPI is an all-in-one notification system with capabilities such as:
Multi-channel support: Email, SMS, In-App
Template Editors
User Preferences Management
After signing up, the dashboard helps you visually design a notification so you don't have to write email HTML/CSS in your code manually.
First, install NotificationAPI's server SDK:
Here's an example of a Supabase Edge Function that sends a welcome notification using NotificationAPI:
You can find the complete code for this guide in our GitHub repository.
SendGrid
SendGrid is an email-only solution, but it's good for both marketing and transactional emails.
After creating an account with SendGrid, you’ll need to complete their onboarding requirements, such as:
Creating a sender identity
Having either a domain or email address you wish to use to send emails
Make sure to select the Web API option during their onboarding when asked which method you will use to send emails.
Here is the sample code to send an email using SendGrid:
Notice that, unlike NotificationAPI, you need to code your own email template using HTML & CSS inside your Supabase Edge Function.
Resend
Resend is an email-only service very similar to SendGrid, also geared towards both marketing and transactional notifications.
This solution requires you to have your own domain in order to send emails, along with a more extensive setup, which will take the longest of our solutions to integrate.
Here's an example of how to send emails using Resend from Supabase Edge Functions:
Notice that, unlike NotificationAPI, you need to code your own email template using HTML & CSS inside your Supabase Edge Function.
Conclusion
If you are looking to send marketing emails, you are better off using Resend or SendGrid. But if you focus more on transactional notifications (product-to-user notifications), NotificationAPI is a stronger tool because of its:
Email and other template editors to make implementation quicker
Bigger free tier
Support for other channels: SMS, In-App, Push, and more.