Overview
The MERN authentication with email verification, hooks, and Docker is a project aimed at providing a fast and easy-to-use boilerplate for implementing authentication in MERN (MongoDB, Express, React, and Node.js) stack applications. It includes features such as email verification, token-based authentication with resend/reset option, server-side sessions, and Docker integration for both development and production environments. The project also utilizes various technologies and dependencies such as React Hooks, TypeScript, Passport-js, and SendGrid API for sending emails. The repository is regularly scanned for vulnerabilities and it is recommended to audit the code before use.
Features
- Email verification with token-based authentication
- Resend/reset password options
- Server-side sessions
- Docker integration for development and production environments
- MongoDB database
- React/Redux frontend
- Node.js/Express backend
- React Hooks for functional components
- TypeScript for typesafety
- Passport-js for local authentication
- SendGrid API for sending emails
Installation
To install the MERN authentication project, follow these steps:
Install Docker if not already installed. Visit https://docs.docker.com/get-docker/ for instructions on how to install Docker.
Set the required environment variables in the
server.dev.envfile. Rename theserver.example.envfile toserver.dev.envand update the following variables:SENDGRID_API_KEY: Get a free key from SendGrid’s website (https://sendgrid.com/) as the backend uses SendGrid to send emails.SESSION_KEY: The secret key used to compute session hashes. It is important to use a strong key.SENDING_EMAIL: The email address used to send confirmation emails to users.
In the root directory, run the following command to start the application in development mode with hot reloading:
docker-compose up --buildTo deploy the application in production mode, set the
server.prod.envandclient.prod.envfiles with the necessary environment variables. Run the following command to start the application in production mode:docker-compose -f docker-compose.prod.yml --env-file client.prod.env up --buildThe frontend application uses an Nginx server to deliver static files. Use the
--remove-orphansflag if needed.
Please refer to https://devcenter.heroku.com/categories/deploying-with-docker for information on deploying the application on Heroku.
Summary
The MERN authentication project provides a boilerplate solution for implementing authentication in MERN stack applications. It offers features such as email verification, password reset options, and server-side sessions. With Docker integration, it becomes easy to develop and deploy the application in both development and production environments. The project utilizes various technologies and dependencies such as React Hooks, TypeScript, Passport-js, and SendGrid API. It is important to note that the repository is regularly scanned for vulnerabilities and it is recommended to review the code before use.