# Route Parameters — Express.js

Source: https://www.geekswithgeeks.com/en/expressjs/ex-route-params

> Capture dynamic segments from the URL path.

## :name syntax

A colon before a path segment, like `:id`, marks it as a parameter. Express captures it into `req.params`.

## Reading a param

`GET /users/42` gives `req.params.id === '42'` — always a string.

```javascript
app.get('/users/:id', (req, res) => {
  const { id } = req.params;
  res.json({ userId: id });
});
```

## Multiple params

A path can have several: `/users/:userId/posts/:postId` fills both `req.params.userId` and `req.params.postId`.
