Universal template to ease out building CRUD apps in MERN
Here are the key commands to set up a MERN stack CRUD app:
mkdir mern-crud
cd mern-crud
mkdir backend frontend
cd backend
npm init -y
npm install express mongoose cors dotenv nodemon
- express: Web framework
- mongoose: MongoDB object modeling
- cors: Enable cross-origin requests
- dotenv: Environment variables
- nodemon: Auto-restart server during development
cd ../frontend
npx create-react-app .
npm install axios react-router-dom
- create-react-app: Creates React project structure
- axios: HTTP client for API requests
- react-router-dom: Client-side routing
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js"
}
mern-crud/
├── backend/
│ ├── models/
│ ├── routes/
│ ├── server.js
│ └── .env
└── frontend/
├── src/
├── public/
└── package.json
# Terminal 1 (backend)
cd backend
npm run dev
# Terminal 2 (frontend)
cd frontend
npm start