Authentication
Mkdirs uses Auth.js v5 for authentication, supports email/password, GitHub, and Google authentication.
Configuration
-
Generate the
AUTH_SECRETvariableAUTH_SECRETis a random value, and you can generate one via running:Terminal window npx auth secret# oropenssl rand -base64 32Then set it to the
.envfile..env # [required]AUTH_SECRET=secret -
[Optional] Get the GitHub client variables
If you want to use GitHub as an OAuth provider, you need to update the
AUTH_GITHUB_IDandAUTH_GITHUB_SECRETvariables.Follow the steps here to get the
client_idandclient_secretfrom the GitHub Developer Settings.For the callback URL, it is
https://your-domain.com/api/auth/callback/githuborhttp://localhost:3000/api/auth/callback/githubfor local development..env # [only required if you want to support GitHub authentication]AUTH_GITHUB_ID = your_secret_client_idAUTH_GITHUB_SECRET = your_secret_client
-
[Optional] Get the Google client variables
If you want to use Google as an OAuth provider, you need to update the
AUTH_GOOGLE_IDandAUTH_GOOGLE_SECRETvariables.You can get the
client_idandclient_secretfrom the Google Cloud Console.For the callback URL, it is
https://your-domain.com/api/auth/callback/googleorhttp://localhost:3000/api/auth/callback/googlefor local development..env # [only required if you want to support Google authentication]AUTH_GOOGLE_ID = your_secret_client_id.apps.googleusercontent.comAUTH_GOOGLE_SECRET = your_secret_client
Video tutorial
If you are interested in Next Auth V5, you can refer to the following video tutorial, it is a more advanced guide for Next Auth V5, so much better than the official documentation.