If you are learning web dev, you already know a bit of Node.js (backend) or React (frontend). But guess what? π Real projects need both working together. In this guide, we will build a very simple full-stack app by connecting Node.js API with a React frontend.
π€ What is Full-Stack?
Backend (Node.js) β talks to database, handles API.
Frontend (React) β shows the data to the user in browser.
When backend + frontend = β€οΈ β you get a full-stack app.
π Step 1: Make a Small Node.js API
server.js:
const express = require("express");
const app = express();
const PORT = 5000;
app.get("/api/message", (req, res) => {
res.json({ message: "Hello from Node.js backend!" });
});
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
npm init -y npm install express node server.jsπ Open http://localhost:5000/api/message and youβll see JSON response.
βοΈ Step 2: Create a React App
npx create-react-app myapp cd myapp npm startThis opens http://localhost:3000 with a starter React page.
π Step 3: Connect React to Node.js
App.js like this:
import { useEffect, useState } from "react";
function App() {
const [msg, setMsg] = useState("");
useEffect(() => {
fetch("http://localhost:5000/api/message")
.then(res => res.json())
.then(data => setMsg(data.message));
}, []);
return (
<div>
<h1>Full Stack App</h1>
<p>{msg}</p>
</div>
);
}
export default App;
export default App;
π Step 4: Test It Out
Start backend β
node server.js(port 5000)Start frontend β
npm start(port 3000)Open browser β http://localhost:3000
π You will see: βHello from Node.js backend!β
π Why This Matters
Node.js = API / data provider
React = UI / data viewer
Together β you created your first full-stack app
This is just the start. Next, you can add database (MongoDB, MySQL), more routes, or even deploy online.
π References & Contact
If you want to learn more, check out the official docs for Node.js and React. You can also read my related blogs: How to Build Your First Node.js API and What is React: My Way of Understanding It.
For questions, feedback, or just to say hi π, you can reach me at info@vaibhavjha.in,Β or on LinkedIn @vaibhavjha08.


