Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Express.js · Module

app.delete

app.delete() registers callback functions for HTTP DELETE requests matching a specified path. The path supports strings, patterns, regular expressions, or arrays of these forms.

How it works

Calling app.delete() registers route handling for HTTP DELETE requests that match the supplied path. The path may be a string, regular expression, or array, and one or more callback functions process matching requests.

Syntax

app.delete(path, callback [, callback ...])

Parameters

NameTypeDescription
pathString | RegExp | ArrayRoute path matched against incoming requests; it may be a string, path pattern, regular expression, or array of combinations.
callback functionsFunctionOne or more callback functions invoked for matching requests.

Returns

Not specified on the documentation page.

Key points

  • Use app.delete() to associate a path with handlers for incoming HTTP DELETE requests.
  • The path accepts a string, path pattern, regular expression pattern, or an array combining these forms.
  • Path matching follows Express path syntax, including the documented path-pattern examples.
  • The historical app.del() alias was introduced to avoid an older JavaScript keyword restriction.

Common mistakes

  • Do not use app.del(); it is deprecated in Express 4.2.0 and later. Register DELETE routes with app.delete().

Example: Delete a user route

const express = require('express');
const app = express();

app.delete('/users/:id', (req, res) => {
  res.send(`Deleted user ${req.params.id}`);
});

app.listen(3000);

This runnable Express app registers a handler for DELETE requests whose path includes a user ID.

When to use it

Resource deletion

Expose a REST endpoint that removes a resource identified by a route parameter.

Precondition middleware

Run authorization or validation before the deletion handler.

Flexible path matching

Match several equivalent DELETE paths or patterns through one route declaration.

Interview questions

QWhat does app.delete() do, and what can its path argument contain?

app.delete() registers callbacks for HTTP DELETE requests matching a specified path. The path can be a string, regular expression, or array of those forms.

Follow-up: How could one support several path forms with one registration? Pass an array containing the desired string, pattern, or regular-expression path values.

QWhat are the main arguments to app.delete()?

The method receives a path followed by callback functions. Express invokes those callbacks when a DELETE request matches the path.

Follow-up: How can route processing be shared before the final handler? Supply multiple callbacks so earlier callbacks can perform middleware work and pass control onward.

QWhy should app.del() not be used?

app.del() is an older alias that existed because delete was reserved in older JavaScript engines. It is deprecated in Express 4.2.0 and later, so app.delete() is the supported spelling.

Follow-up: What migration change is needed when moving to Express 5? Replace app.del() calls with app.delete(), because Express 5 no longer supports the alias.

  • app.METHOD()
  • app.get()
  • app.post()
  • app.put()
  • app.all()
  • app.use()
  • app.del()

Source: Application Object · Express.js 4.x. Checked 2026-10-15.