Skip to main content

Command Palette

Search for a command to run...

What is routing and how routing works in Express.js?

Updated
1 min read
What is routing and how routing works in
Express.js?

Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).

Each route can have one or more handler functions, which are executed when the route is matched.

The following example illustrates defining simple route. Respond with Hello World! on the homepage:

app.get('/', (req, res) => {
  res.send('Hello World!')
})

Source:

Express Basic Routing. expressjs.com/en/starter/basic-routing.html.

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference