Adding react-email to a nextjs app
- tags
- nextjs
- react-email
- resend
- vercel
Contents
First add your dependencies
| |
Create a new folder to store the emails. This lives next to my app
directory.
| |
Add a script in package.json to help with testing:
| |
Create the email
I'm going to copy an example over from https://www.reactemailtemplate.com/components/articles since this is just demonstration.
Lets put something in src/emails/welcome.tsx
Start up the email dev server to see if you like it, and edit it however you'd like.
| |
Create a send email action
This is here to organize the code, and will be invoked by the server.
| |
Write a test page
This using server compoent actions. The sendEmail method will be
invoked on the server, which has access to the api key.
| |
Deploying to vercel
Add RESEND_API to the environment, and then just push and test it out.
This is my first time using server components, and it's confusing but pretty nifty.
Previously
Next