Home Express.js Application app.enabled() Express.js app.enabled() Method Definition In Express.js, app.enabled(name) returns true when an application setting is currently enabled (on / truthy). It is a read-only check — it never changes settings.
Use it after app.enable() (or instead of comparing app.get(name) === true). The opposite helper is app.disabled() .
Syntax Call app.enabled in your Express.js app. Start with this line.
Call What it does app.enabled(name)Primary signature.
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 const express = require("express");
const app = express();
app.enabled(name) Parameters Parameter Description name Required. Setting to test — for example 'trust proxy' or 'x-powered-by'. true Required. The setting is enabled (on / truthy). false Required. The setting is not enabled (off / falsy).
Return Value app.enabled(name) returns a Boolean: true if the setting is enabled (truthy), otherwise false. It does not change any setting.
app.enable('trust proxy');
app.enabled('trust proxy'); // true
app.enabled('view cache'); // depends on NODE_ENV / prior sets Express.js Examples 1. Official check pattern 2. Check x-powered-by 3. Branch on enabled Example 1 — Official Check Pattern Default is off for trust proxy; enable it, then confirm with app.enabled() (Express docs style).
const express = require('express');
const app = express();
console.log(app.enabled('trust proxy')); // false
app.enable('trust proxy');
console.log(app.enabled('trust proxy')); // true
app.listen(3000); How It Works Check the default. trust proxy starts off, so app.enabled(...) is false.Turn the flag on. app.enable('trust proxy') stores true.Ask “is it enabled?” app.enabled(...) now returns true.Read-only. The check never mutates the setting.Example 2 — Check x-powered-by See the default (on), then disable and re-check with both helpers.
const express = require('express');
const app = express();
console.log(app.enabled('x-powered-by')); // true (default)
console.log(app.get('x-powered-by')); // true
app.disable('x-powered-by');
console.log(app.enabled('x-powered-by')); // false
console.log(app.disabled('x-powered-by')); // true
app.listen(3000); How It Works Default is on. Before changes, app.enabled('x-powered-by') is true.Raw value. app.get(...) shows the stored Boolean (true).Disable. app.disable(...) turns the flag off.Helpers agree. enabled becomes false; disabled becomes true.Example 3 — Branch on enabled Use the check in a status route to report production settings.
const express = require('express');
const app = express();
if (process.env.NODE_ENV === 'production') {
app.enable('trust proxy');
app.disable('x-powered-by');
}
app.get('/status', (req, res) => {
res.json({
trustProxyOn: app.enabled('trust proxy'),
poweredByOn: app.enabled('x-powered-by')
});
});
app.listen(3000); NODE_ENV=production → GET /status
{ "trustProxyOn": true, "poweredByOn": false }
NODE_ENV unset → GET /status
{ "trustProxyOn": false, "poweredByOn": true } How It Works Optional setup. Production enables trust proxy and hides X-Powered-By.Read in a route. app.enabled(...) reports each flag as JSON.Defaults elsewhere. Without production, trust proxy stays off and x-powered-by stays on.No mutation. The check only reads; it never flips the setting.Compatibility
Runtime Support app.enabled() is an Express.js application method . It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not call it.
✓ Server · Express 4 & 5
app.enabled() 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.enabled() 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 What does Express.js app.enabled() do? It returns true when a named application setting is currently enabled (truthy / on). It only reads the setting — it does not change it.
How is app.enabled() different from app.enable()? app.enable(name) turns the setting on. app.enabled(name) only checks whether it is currently on.
How does app.enabled() relate to app.disabled()? They are opposite checks. If app.enabled(name) is true, then app.disabled(name) is false for a Boolean setting.
Should I use app.enabled() or app.get()? Use app.enabled(name) when you want a clear yes/no “is it on?” answer. Use app.get(name) when you need the raw stored value.
Can browsers run app.enabled()? No. It runs on your Express server in Node.js. Browsers only see the HTTP result of your app’s settings.
CODETOFUN NEWS
Stay Ahead in Tech Get the latest IT news, programming updates, and technology trends directly on your phone.
About the author Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion