Skip to main content
D
Node.js
Express Routing

Express Routing

Express routing handles different URL paths and HTTP methods.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

When a user visits your website, they request a specific URL path, like `/about` or `/contact`. Express routing acts like a traffic cop, directing the user's request to the correct block of code based on the URL they typed.

Example

Example
1/* this creates routes */
2app.get('/users', (req, res) => {
3  res.send('Show all users');
4});
5
6app.post('/users', (req, res) => {
7  res.send('Create a new user');
8});

Key Points

  • Routes use HTTP methods like GET, POST, PUT, and DELETE.
  • `app.get()` retrieves data from the server.
  • `app.post()` sends new data to the server.
  • The `req` object holds the user's data.

Up Next

Continue your journey with the next topic.

Go to Express Middleware