DEV Community

Cover image for How to create Email Verification using NextJS
Nicholas
Nicholas

Posted on

How to create Email Verification using NextJS

Email verification is a vital part of user authentication as it ensures inputed user email is correct and it validates without a doubt the credibility of the provided authentication credentials. Implementing this feature can be a drag so I am going to try to show you how I do it.

  • First set up your nextJs project Image description

create a lib folder and inside the folder create an actions.js file that will contain the registration logic

Image description

install these dependencies: using npm I nodemailer jsonwebtoken bcryptjs ejs

connect your database

Image description

create a sendMail function in a separate file

Image description

create a mail template

Image description

implement your action.js like thus
Image description

then use the logic in a registration form

Image description

you should be able to send the user a link to verify their mail when this is done

Top comments (0)