You map HTTP methods and URL paths to handlers with app.get, app.post, etc. Use :name for URL params (req.params), ?key=value for query strings (req.query), and express.Router to group routes by feature.
Express Routing Basics: Methods and Paths
How does routing work in Express?
The answer
More FAQs in Express Routing Basics: Methods and Paths
GET for reading (safe, idempotent), POST for creating, PUT for full replace, PATCH for partial update, DELETE for removing. Pick by semantics, not by habit.
Define a route with :name: /users/:id. Read it with req.params.id. Params are always strings. Convert to ObjectId or number when needed.
For grouping routes by feature. You create a router in routes/users.js, add routes to it, and mount it in app.js with app.use('/users', usersRouter). Cleaner than putting every route in app.js.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.