A simple MERN (MongoDB, Express, React, Node.js) starter project with authentication. This template provides the essential building blocks for a login/signup system so you can quickly build and expand into a full application!
- π User authentication (signup & login)
- π‘οΈ Password hashing with bcrypt
- π¦ Backend API built with Express & MongoDB
- βοΈ Frontend with React & Vite
- π‘ API requests handled via Axios
- π Ready-to-extend template for dashboards, CRUD apps, and more (Depending on your project)
mern-stack/
βββ client/ # Frontend (React + Vite)
β βββ node_modules/
β βββ public/
β βββ src/
β β βββ App.jsx
β β βββ Home.jsx
β β βββ Login.jsx
β β βββ Signup.jsx
β β βββ main.jsx
β βββ .gitignore
β βββ eslint.config.js
β βββ index.html
β βββ package-lock.json
β βββ package.json
β βββ vite.config.js
β
βββ server/ # Backend (Node.js + Express + MongoDB)
β βββ models/
β β βββ Account.js
β βββ node_modules/
β βββ .env
β βββ .gitignore
β βββ index.js
β βββ package-lock.json
β βββ package.json
β
βββ README.md
git clone https://github.com/denverdelamasa/mern-stack.git
cd mern-stackcd server
npm installcd ../client
npm installCreate a .env file in the backend directory with the following keys:
PORT=3001
MONGO_URI=mongodb://127.0.0.1:27017/account
JWT_ACCESS_SECRET=supersecret-access-key
JWT_REFRESH_SECRET=supersecret-refresh-keycd server
npm startcd client
npm run devFrontend runs on http://localhost:5173 and backend on http://localhost:3001 (by default).
- Go to http://localhost:5173
- Sign up for a new account
- Log in with your credentials
- After login, youβll be redirected to the
Homepage (example protected route)
MongoDB Permission Issues on Windows
Some users may encounter (because I did) an error when trying to start MongoDB due to permission issues if itβs installed inside C:/Program Files.
Fix:
- Uninstall MongoDB.
- Reinstall it directly in
C:/(e.g.,C:/MongoDB/) instead ofC:/Program Files/. - Make sure the
mongodservice points to the new installation path.
This avoids Windows permission conflicts and ensures MongoDB runs correctly!
This is meant to be a starter template. Feel free to fork and adapt for your own projects. Contributions are welcome via pull requests!
Goodluck on your project!!!
This project is open-source and available under the MIT License.