Introduction to MERN Stack | Download MongoDB & Express JS 🚀🍃
Our News App frontend is finally ready — it fetches, paginates, and displays articles
beautifully with React. But right now, everything runs only in the browser. To make our
News App truly production-ready, with a real database, a real API, and real user data,
we need to step into the MERN Stack: MongoDB, Express.js, React.js, and Node.js.
In this tutorial, we will learn:
What the MERN Stack is and what each letter stands for
Why the MERN Stack is a popular choice for full-stack web development
How data flows between MongoDB, Express, React, and Node
How to download and install MongoDB on your system
How to verify your MongoDB installation is working correctly
How to set up a Node project and install Express.js
How to write and run a basic Express server
---
What is the MERN Stack?
MERN is a popular JavaScript full-stack technology bundle used to build
dynamic, database-driven web applications end to end using a single language —
JavaScript. The name is an acronym made up of four technologies:
M — MongoDB: a NoSQL database that stores data as flexible, JSON-like documents
E — Express.js: a lightweight Node.js framework for building REST APIs and web servers
R — React.js: a JavaScript library for building fast, component-based user interfaces
N — Node.js: a JavaScript runtime that lets us run JavaScript on the server
Together, these four technologies let developers write both the frontend and the
backend in JavaScript — which is exactly what makes MERN so beginner-friendly and
efficient for projects like our News App.
---
Why Use MERN Stack for Our News App?
Right now, our News App articles live only inside component state — refresh the page and
they're gone. With MERN, we can:
Store saved or bookmarked articles permanently in MongoDB
Build a real REST API with Express.js to serve news data
Keep using React for the frontend we've already built
Run everything on a single Node.js server
Use one language — JavaScript — across the entire app
---
How Data Flows in a MERN Application
Understanding the request flow makes the rest of this series much easier to follow:
| Step |
What Happens |
| 1 |
React (frontend) sends a request to the Express server |
| 2 |
Express (backend) receives the request and processes it via Node.js |
| 3 |
Express queries or updates data in MongoDB |
| 4 |
MongoDB sends the result back to Express |
| 5 |
Express sends a JSON response back to React |
| 6 |
React updates the UI with the new data |
---
Step 1: Download MongoDB
MongoDB is the database layer of our stack. To get started:
Go to the official MongoDB Community Server download page
Select your operating system — Windows, macOS, or Linux
Download the MSI installer (Windows) or the appropriate package for your OS
Run the installer and choose the "Complete" setup type
Make sure "Install MongoDB as a Service" is checked so it runs in the background
Optionally install MongoDB Compass — a GUI tool to view your database visually
---
Step 2: Verify Your MongoDB Installation
Once installed, open your terminal or command prompt and check the version to confirm
MongoDB was installed correctly.
You can also start the MongoDB shell to connect to your local database:
If you see version numbers and a connected shell prompt, your MongoDB installation is
working correctly and ready for our News App backend.
---
Step 3: Set Up a Node Project
Before installing Express, we need a Node.js project. Create a new folder for your backend
and initialize it with npm.
mkdir news-app-backend
cd news-app-backend
npm init -y
This creates a package.json file that will track all our backend dependencies —
including Express.
---
Step 4: Download & Install Express.js
Express.js is installed as an npm package inside your Node project — there's no
separate installer to download.
Once installed, you'll see express listed under dependencies in your
package.json file.
---
Step 5: Create a Basic Express Server
Let's write a minimal index.js file to confirm Express is working.
const express = require("express");
const app = express();
const PORT = 5000;
app.get("/", (req, res) => {
res.send("Welcome to the News App Backend 📰🚀");
});
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});
Run the server with:
Open http://localhost:5000 in your browser — if you see the welcome message,
your Express server is up and running. 🎉
---
MERN Stack Components at a Glance
| Technology |
Role |
Used For |
| MongoDB |
Database |
Storing news articles, users, and saved/bookmarked data |
| Express.js |
Backend Framework |
Building REST API routes and handling server logic |
| React.js |
Frontend Library |
Rendering the News App UI (already built!) |
| Node.js |
Runtime Environment |
Running JavaScript on the server |
---
Features and Learnings:-
Understood what the MERN Stack is and what each letter — MongoDB, Express, React, Node — represents.
Learned why MERN is a great fit for turning our News App into a full-stack application.
Traced how data flows between the frontend, backend, and database in a MERN app.
Downloaded and installed MongoDB Community Server on our system.
Verified the MongoDB installation using mongod --version and mongosh.
Initialized a new Node.js project using npm init.
Installed Express.js via npm and built our first working Express server.
Prepared the foundation for the next step: connecting Express to MongoDB and building a real News API.