S
Background
Open Source5 min readJan 20, 2026

Building create-mern-auth: An Open-Source CLI to Eliminate Auth Boilerplate

Tired of setting up JWT, OTPs, and auth routes for every new project? Here's how I built and published create-mern-auth to npm.

Published By
Sameer Bagul

Sameer Bagul

Software Engineer

Topics Covered
#OPENSOURCE#NPM#NODE.JS#MERN#JWT#REACT

Tired of setting up JWT, OTPs, and auth routes for every new project? Here's how I built and published create-mern-auth to npm.

The Developer Friction

Every developer knows the pain: starting a new hackathon project, SaaS MVP, or freelance client app, and spending the first 4 hours configuring the exact same authentication pipeline:

  • JWT token handling & Refresh tokens
  • OTP generation & Email verification
  • Password reset flows
  • Protected React routes & Express middleware
  • Dark/Light mode landing page & Dashboard UI

If you're using AI tools like Cursor or Copilot, you're literally burning tokens generating boilerplate setup over and over again.


The Solution: npx create-mern-auth

I built create-mern-auth to bootstrap a battle-tested MERN authentication pipeline with a single CLI command:

npx create-mern-auth my-app

Out-of-the-Box Features

  • JWT + OTP Authentication: Dual-layer security with Nodemailer integration.
  • Email Verification & Password Reset: Pre-wired backend endpoints and React forms.
  • Protected Routes: Pre-configured React Context and client-side guards.
  • Modular Architecture: Separate client (React + Tailwind) and server (Node.js + Express + MongoDB) directories ready for immediate deployment.

Lessons in Publishing Open-Source CLI Packages

Creating an npm CLI tool required understanding Node bin scripts, Commander.js argument parsing, and interactive inquirer prompts. Check out the open-source code on GitHub and contribute!