More Premium Hugo Themes Premium React Themes

Mern Authentication

MERN stack authentication boilerplate: password reset, email verification, server sessions, redux, typescript, hooks and docker for dev and prod.

Mern Authentication

MERN stack authentication boilerplate: password reset, email verification, server sessions, redux, typescript, hooks and docker for dev and prod.

Author Avatar Theme by flaviuse
Github Stars Github Stars: 506
Last Commit Last Commit: Aug 7, 2025 -
First Commit Created: Jun 19, 2023 -
Mern Authentication screenshot

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:

  1. Install Docker if not already installed. Visit https://docs.docker.com/get-docker/ for instructions on how to install Docker.

  2. Set the required environment variables in the server.dev.env file. Rename the server.example.env file to server.dev.env and 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.
  3. In the root directory, run the following command to start the application in development mode with hot reloading:

    docker-compose up --build
    
  4. To deploy the application in production mode, set the server.prod.env and client.prod.env files 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 --build
    
  5. The frontend application uses an Nginx server to deliver static files. Use the --remove-orphans flag 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.