How to send OTP verification email notifications with React-email
Learn how to send OTP verification email notifications with React-email in your NextJS app
Introduction
In this guide, you’ll learn how to send OTP verification email notifications using the React-email package. Follow these steps:
Getting started
Integrating Novu’s code-first workflow with React.Email for your Next.js application can be done in a few steps:
- Create a NextJS app and wait for the installation:
- Once this installation is complete, simply
cd
into the directory and start your app using thenpm run dev
command.
Using a code-first workflow
- Write an email template - To write an email template, you can look over some of the examples in the React Email documentation to get inspiration. In our case, this is the template:
- Launch Dev Studio - Novu’s code-first approach lets you see how the template would look when rendered, right when defining it, using the Dev Studio. To launch the dev studio locally you can run
npx novu-labs@latest echo
. The Dev Studio will be started by default on port 2022, and accessible via: http://localhost:2022
Dev Studio lets you see the workflow you wrote without sending it off!
- Define a workflow that uses that template to send notifications - In this step, we need to define a workflow that uses the template we wrote above to render the email notification:
- Triggering the workflow - Lastly, we need to trigger the workflow we created above. Here’s how to trigger it:
When we trigger this workflow, here’s the email received on the client-side:
The workflow as delivered on a client-side device
That’s it!
That’s how you create and use an OTP workflow. You can check out our docs for a hands on guide with more in-depth instructions.
Once you’ve built the workflow, you might want read one of our other guides on how to empower product teams to manage notification workflows.
Don’t forget to share your workflows with us and as always, hit us up on Discord with any questions you might have!