JavaScript on the server — one language for everything.
Node.js is a runtime that lets JavaScript — the language of the browser — run on a server. That means the same language you use for frontend interactivity can also handle requests, talk to databases, and build APIs. Express is the most popular Node web framework: a thin, flexible layer that maps URLs to functions and handles the request/response details.
Together they power one of the largest developer ecosystems in the world. npm, Node's package registry, has a library for nearly anything you'll ever want to do.
Node + Express is the natural backend if you're already learning JavaScript for the frontend — one language across the whole stack, and it pairs seamlessly with React or Vue. It's especially good for APIs and real-time apps. It needs a VPS or platform service (it won't run on classic shared hosting, where PHP wins), and if you'd rather learn the most readable language first, Python + Flask is the gentler start.
package.json;
npm install fetches them into
node_modules.
app.get("/users", handler).
async/await so the server keeps handling other
requests meanwhile. This is Node's superpower and the biggest
beginner hurdle.
import express from "express";
const app = express();
app.use(express.json());
app.get("/api/hello", (req, res) => {
res.json({ message: "Hello from Express!" });
});
app.listen(3000, () => console.log("Running on port 3000"));
Run node server.js and you have a JSON API at
localhost:3000/api/hello — ready for a React or Vue
frontend to fetch from.
async.
npm init -y and npm install express in
a new folder.