Node.js Express Introduction

The most popular Node web framework.

✍️ 2 exercises in this lesson

Express is a minimal web framework for Node.js. It adds routing, middleware and helpers on top of the http module.

  1. npm install express
  2. Create the app: const app = express();
  3. Define routes: app.get("/", (req, res) => res.send("Hi"))
  4. Start: app.listen(3000)

Key Takeaways: Node.js Express Introduction

Mastering Node.js Express Introduction helps you write clean and reliable Node.js code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Node.js Express Introduction Code Example

Node.js
import express from "express";

const app = express();

app.get("/", (req, res) => {
  res.send("<h1>Welcome to my Express app</h1>");
});

app.get("/api/hello", (req, res) => {
  res.json({ message: "Hello", time: Date.now() });
});

app.listen(3000, () => console.log("Listening on http://localhost:3000"));
Output
Listening on http://localhost:3000
Run this example on your own computer. The "Get Started" lesson shows how to set it up.

Node.js Express Introduction Practice Exercises

Check what you learned in “Node.js Express Introduction”.

/ 2 solved
Fill in the blank

Define a GET route.

app.("/", (req, res) => res.send("Hi"));
✓ Correct! Not quite. Try again.
Multiple choice

Which method starts the Express server?

✓ Correct! Not quite. Try again.
to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services