Email verification
Most Web-Apps these days require email verification for new users. As the Laravel Next.js Starter Kit leverages Laravel Sanctum on the backend, the API functionality for email verification comes right out of the box.
Important: If you want email verification in your project you MUST properly configure your email settings. Otherwise the application will break, as the Laravel API wants to send an email but does not find the right settings. Find out how to do that in the „Email settings" section.
Once that’s done you can test things out on the frontend. Visit /user/register
and create an account. Afterwards, check your email inbox (e.g. MailTrap) for new mails. You will se a new mail with a link to a URL. Click it. By opening the page, a request with information from the URL will be sent to the API. If the verification was successful, you will be redirected to your User Home Route (set in /client/.env.local
). If the verification fails an error message will be displayed and you will not be redirected.
If you don’t want email verification on your project, navigate to app/Models/User
and delete the implements MustVerifyEmail
part of the class definition statement. Then, delete the client/pages/user/email
directory and delete the verifyEmail
function in /client/store/auth/authActions.tsx
. For security reasons you might also want to deny access to the backend route from the frontend to the API. To accomplish this, open /config/cors.php
and delete "email/verify/*"
from the paths
array.