request.params

The matched route parameters parsed from the URL path.

Since Fastify 5 Spec ↗

Syntax

request.params

Returns

object — A key/value map of route parameters.

Examples

import Fastify from 'fastify';

const app = Fastify();

app.get<{ Params: { id: string } }>('/cats/:id', async (req) => {
  return { id: req.params.id };
});

Notes

Define a `params` JSON Schema to coerce types (e.g. string to integer) and validate. With TypeScript route generics the params type flows into the handler.