Express.js app.delete() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Application

Definition

In Express.js, app.delete() registers handlers for HTTP DELETE requests on a path. A typical REST API uses it to remove a resource, for example DELETE /users/42.

It is one of Express’s app.METHOD() routing methods: only DELETE matches. GET or POST to the same URL need their own routes. Express runs on a Node.js server — browsers only send the DELETE request.

Syntax

Call app.delete in your Express.js app. Start with this line.

Express
app.delete(path, callback)
app.delete(path, ...callbacks)
CallWhat it does
app.delete(path, callback)Primary signature.
app.delete(path, ...callbacks)Related call form.

Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.

Library declarations
Express
const express = require("express");
const app = express();

app.delete(path, callback)
app.delete(path, ...callbacks)

Parameters

ParameterDescription
pathRequired. Route path to match for DELETE. Strings match the whole path. Arrays match any listed path.
callbackRequired. One or more handlers: (req, res, next) => { … }. Can call next('route') to skip remaining callbacks on this route.

Return Value

app.delete() returns the same application object (app), so chaining is possible. In real apps you almost always ignore the return value and register each route on its own line.

Express
// Chaining works, but is uncommon:
app.delete('/items/:id', remove).get('/items', list);

// Typical style — ignore the return value:
app.delete('/items/:id', remove);
app.get('/items', list);

Express.js Examples

Example 1 — Basic DELETE Route

Respond to DELETE /user with a simple message.

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

app.delete('/user', (req, res) => {
  res.send('Got a DELETE request at /user');
});

app.listen(3000);

How It Works

  1. Register DELETE only. app.delete('/user', …) ignores GET and POST.
  2. Match the path. A DELETE to /user enters the handler.
  3. Send a body. res.send(…) finishes the response with status 200 by default.
  4. Other verbs need other routes. Add app.get('/user') if you also want to read the resource.

Example 2 — Delete by Id

Use a path parameter and remove one item from an in-memory list.

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

const users = new Map([
  ['1', { id: '1', name: 'Ada' }],
  ['2', { id: '2', name: 'Lin' }]
]);

app.delete('/users/:id', (req, res) => {
  const id = req.params.id;
  if (!users.has(id)) {
    return res.status(404).json({ error: 'Not found' });
  }
  users.delete(id);
  res.json({ deleted: id });
});

app.listen(3000);

How It Works

  1. Capture the id. /users/:id puts the segment into req.params.id.
  2. Look up the resource. If the map has no entry, return 404 and stop.
  3. Remove it. users.delete(id) updates the store.
  4. Confirm with JSON. res.json({ deleted: id }) returns 200 and a clear body.

Example 3 — Prefer 204 No Content

When the client does not need a body, end with status 204 after a successful delete.

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

const notes = new Set(['a', 'b']);

app.delete('/notes/:id', (req, res) => {
  const id = req.params.id;
  if (!notes.has(id)) {
    return res.status(404).end();
  }
  notes.delete(id);
  res.status(204).end();
});

app.listen(3000);

How It Works

  1. Same param pattern. :id selects which note to remove.
  2. Missing → 404. res.status(404).end() sends no body.
  3. Success → 204. res.status(204).end() means “done, nothing to return”.
  4. Use 200 when you need a body. Prefer example 2’s JSON style if the client must see what was deleted.

Runtime Support

app.delete() is an Express.js application method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not execute it — they only send HTTP DELETE requests.

✓ Server · Express 4 & 5

app.delete()

Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.

Server Node.js runtime API
Node.js 18+ for Express 5 · 14+ typical for Express 4
Supported
Bun Express-compatible server apps
Supported
Deno Via npm compatibility / adapters
Supported
app.delete() Express on Node.js

Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.

Frequently Asked Questions

It registers one or more handlers for HTTP DELETE requests on a path. Only DELETE matches — GET or POST to the same path need their own routes.
Common choices are 200 with a JSON body, 204 with no body, or 202 if deletion is accepted but finished later. Use 404 when the resource is missing.
Use a route parameter such as /users/:id and read req.params.id inside the handler.
No. Express 5 removed app.del(). Use app.delete() instead.
No. Express runs on a Node.js server. Browsers only send HTTP DELETE requests to your API.

Next: app.disable()

Turn off an Express application setting with a single call.

app.disable() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful