app.delete()

Registers a route handling HTTP DELETE requests for resource removal.

Since Fastify 5 Spec ↗

Syntax

app.delete(url, options?, handler)

Parameters

NameTypeRequiredDescription
url string No The route path.
options RouteShorthandOptions No Optional schema, hooks, and config.
handler Function No Async handler receiving (request, reply).

Returns

FastifyInstance — The instance, for chaining.

Examples

import Fastify from 'fastify';

const app = Fastify();

app.delete<{ Params: { id: string } }>(
  '/cats/:id',
  async (req, reply) => {
    reply.code(204);
    return null;
  },
);

Notes

DELETE is idempotent. Return reply.code(204) with a null body when there is nothing to send back.