A production-ready MERN starter with an Express + MongoDB API and a React (Vite) frontend.
It includes a complete User CRUD example so you can quickly extend the project for your own features.
- Backend: Express + Mongoose API under
/api - Frontend: React 18 + Vite + RSuite
- Database: MongoDB (local or hosted via
MONGODB_URI) - Includes: end-to-end
Usercreate/read/update/delete flow - UI theming: token-based styles with light, dark, and high-contrast modes
- Node.js
- Express
- Mongoose
- CORS
- dotenv
- concurrently + nodemon (dev workflow)
- React 18
- Vite
- React Router v6
- RSuite v5
- Axios
The frontend includes a token-driven style system in client/src/App.css:
- Theme modes:
light,dark,high-contrast - Global CSS variables for surfaces, text, borders, buttons, status colors, and focus states
- Reusable utility/base classes for layout and components (
.container,.section,.stack,.row,.card,.btn-*, etc.) - Navbar theme toggles persist user preference in
localStorage
Theme mode is applied through data-theme on :root and theme classes on body/#root.
- Node.js 18+ recommended
- npm
- MongoDB instance (local or cloud)
From the project root:
npm install
npm run client:installThis installs backend dependencies first, then client dependencies.
npm startThis starts:
- Express API server on
http://localhost:3001 - Vite client dev server on
http://localhost:3000
The Vite dev server proxies /api requests to http://localhost:3001.
Create a .env file in the project root as needed:
MONGODB_URI=mongodb://localhost/mern_template
PORT=3001
NODE_ENV=developmentNotes:
- If
MONGODB_URIis not set, the app defaults tomongodb://localhost/mern_template. PORTdefaults to3001.
npm start: Runs production or development mode based onNODE_ENVnpm run dev: Alias forstart:devnpm run client:install: Installs frontend dependenciesnpm run start:dev: Starts nodemon server + Vite clientnpm run start:prod: Starts Express server onlynpm run build: Builds the frontend intoclient/dist
npm run dev(insideclient): Runs Vite dev servernpm run build(insideclient): Production buildnpm run preview(insideclient): Preview built client
User routes:
GET /api/users- list usersPOST /api/users- create userGET /api/users/:id- get user by idPUT /api/users/:id- update userDELETE /api/users/:id- delete user
MERN_app-template/
|- app/
| |- controllers/
| |- models/
| |- routes/
|- client/
| |- src/
| |- index.html
| |- vite.config.mjs
|- DEPLOYMENT.md
|- server.js
|- package.json
Platform-specific deployment steps are documented in DEPLOYMENT.md, including:
- Render
- Replit Deployments
- Heroku
- Railway
It also includes required environment variables, build/start commands, and common production troubleshooting.
- Build the client with
npm run buildfrom the root. - In production mode (
NODE_ENV=production), Express serves static assets fromclient/dist. - For full hosted deployment instructions, see
DEPLOYMENT.md.
- Add request schema validation middleware for all API endpoints.
- Add authentication and role-based authorization.
- Introduce automated backend and frontend test coverage in CI.
- Add Docker development and deployment configuration.
- Publish API reference with OpenAPI/Swagger.
Contributions are welcome. To keep changes easy to review and maintain:
- Fork the repository and create a focused feature branch.
- Keep pull requests scoped to one logical change.
- Update documentation when behavior or scripts change.
- Verify the app builds successfully before opening a PR.
- Include clear PR descriptions with testing notes.
ISC