Sending email with react-email
its nicer to use their interative builder but why not just the simple thing
- tags
- react
- htmlq
- reactemail
Contents
Install stuff we'll need:
|
|
Which installs so much stuff…
|
|
336 446M node_modules
And gives us something like:
|
|
A quite little tsup.config.ts:
|
|
Then we need to configure typescript, like so:
// tsconfig.json
|
|
Make the template
The npm run emaildev
command looks for things in the emails
folder,
and it's really handle to have the preview while you edit.
|
|
I just played around with some different options of things to do, it works pretty well.
|
|
Test the templates
|
|
This will open up a server on port 3000
that will let you live preview
the changes that you make!
Render the template
|
|
|
|
There's not really a big reason to do this other than to see how it works. We are going to use resend below to actually trigger the sending of the message.
Send with resend
Resend is a new service that makes it easier to send emails, and they were the ones that wrote react.email so of course the fit together nicely!
|
|
Testing
I'm pulling the API key out of 1password:
|
|
And then:
|
|
Email sent { data: { id: '6185f47f-f825-46f1-8557-a432ad2ccfc1' }, error: null }
Previously
Next