Description #
Express.js is a fast, unopinionated, minimalist web framework for Node.js. It simplifies building APIs and web applications by providing robust features for routing, middleware, and HTTP utilities, making it one of the most popular backend frameworks in JavaScript.
History #
Created by TJ Holowaychuk in 2010, Express.js was built on top of Node.js to handle HTTP routing and middleware more efficiently. It quickly became the foundation for many full-stack JavaScript frameworks like MEAN and MERN, and is now maintained as part of the OpenJS Foundation.
Hello World Code #
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello, World!');
});
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});
How to Run #
Option 1: Online
Option 2: Local
Initialize a Node.js project:
npm init -y
npm install express
Save the code as app.js
Run:
node app.js
Key Concepts #
- Built on top of Node.js
- Simple route handling with
app.get
,app.post
, etc. - Middleware support (logging, authentication, etc.)
- RESTful API development
- Static file serving
- Templating engine support (e.g., Pug, EJS)
- Scalable for large apps
- Ideal for single-page app (SPA) backends
- Works well with MongoDB and front-end frameworks
- Foundation for full-stack stacks like MERN/MEVN
Try It Online #
Fun Facts #
- Express.js powers millions of web apps and APIs.
- It’s often the first backend framework new JavaScript developers learn.
- It’s the “E” in MEAN and MERN stack.