In Express.js, app.post() registers handlers for HTTP POST requests on a path. APIs often use it to create a resource, for example POST /users with a JSON body.
Required. Route path to match. Strings match the whole path. Arrays register the same handlers for each path.
callback
Required. Middleware-style handlers (req, res, next). You may pass several, or an array of them.
Return Value
app.post() 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.post('/login', login).get('/login', form);
// Typical style — ignore the return value:
app.post('/login', login);
app.get('/login', form);
Express.js Examples
Example 1 — Basic POST Route
Official-style homepage POST — no body parsing needed.
POST /signup
{"email":"[email protected]"}
→ 201 { "ok": true, "email": "[email protected]" }
POST /signup
{}
→ 400 { "error": "email is required" }
How It Works
Shared check.requireEmail runs first like middleware.
Fail early. Bad input sends 400 and never calls the next function.
Continue.next() moves to the create handler.
Respond. The final callback returns 201 with a small JSON body.
Compatibility
Runtime Support
app.post() is an Express.js application method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers only send the POST request.
✓ Server · Express 4 & 5
app.post()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
app.post()Express on Node.js
Bottom line: Run examples with Node.js and the express package, then POST with curl, Postman, or fetch.
Frequently Asked Questions
It registers one or more handlers for HTTP POST requests on a path. Only POST matches — GET or PUT to the same path need their own routes.
Express does not parse JSON or form bodies by default. Add express.json() or express.urlencoded() before your routes so req.body is filled.
Often 201 Created with the new resource (or its id) in the body. 200 is fine for simple acknowledgements; 204 if there is no body to return.
No. Like other app.METHOD routes, a string path matches the whole request path. app.post('/apple') matches /apple, not /apple/images — unlike app.use('/apple').
No. Express runs on a Node.js server. Browsers only send HTTP POST requests (forms, fetch, XHR) to your API.