helmet

Secure Node and Express apps by setting protective HTTP response headers with a single line of middleware.

Library
npm
v8.3.0
10,736 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
71 /100 Good
Development Activity 80
Maintenance 44
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
88 /100 Excellent
Architecture 85
Code Quality 88
Innovation 92
Learning Curve 88

Helmet is a collection of Express middleware functions that set security-related HTTP response headers to help protect your app from a range of well-known web vulnerabilities. Calling helmet() applies sensible defaults for roughly a dozen headers, including Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, and Cross-Origin-Resource-Policy.

Each header is implemented as its own standalone middleware, so you can enable the full bundle, disable individual headers, or fine-tune any of them with header-specific options. Helmet aims to be quick to integrate and low maintenance afterward, making it a common baseline for hardening Node.js web servers.

What You Get

  • A one-line helmet() middleware that sets around a dozen protective HTTP response headers with sensible defaults.
  • Individually configurable headers, each of which can be disabled or tuned via a dedicated options object.
  • Standalone middleware exports (e.g. helmet.contentSecurityPolicy()) so you can apply a single header on its own.
  • First-class TypeScript types for every header’s options, with descriptive runtime errors for misconfiguration.

Common Use Cases

  • Hardening an Express API or web app against common attacks by applying a security-header baseline.
  • Defining and enforcing a Content-Security-Policy to mitigate cross-site scripting and injection.
  • Enforcing HTTPS with Strict-Transport-Security (HSTS) across a domain and its subdomains.
  • Controlling cross-origin resource, opener, and embedder behavior for process isolation and resource protection.

Under The Hood

Architecture — Helmet is organized as a thin composition layer over a set of independent middleware modules. The middlewares/ directory holds one folder per header (content-security-policy, strict-transport-security, referrer-policy, cross-origin-*, x-frame-options, and so on), each exporting a default middleware factory plus its own options type. The root index.ts imports every factory, defines a combined HelmetOptions type that maps each key to either the header’s options or a boolean, and returns a single middleware that instantiates the enabled sub-middlewares once at startup and invokes them per request. Legacy aliases (e.g. hsts, frameguard, noSniff) are supported through a TypeScript EitherKey helper that prevents passing both the modern and legacy name at once.

Tech Stack — The library is written in TypeScript (95% of the codebase) targeting Node.js >=18 and ships as an ES module with no runtime dependencies. The build is driven by a custom build/build-package.ts script run through tsx on top of Rollup with @rollup/plugin-typescript and rollup-plugin-dts to emit JavaScript plus bundled type declarations. Tooling includes ESLint (typescript-eslint), Prettier, and tsc --noEmit for type checking.

Code Quality — Test coverage is thorough: the test/ directory contains a dedicated .test.ts suite per middleware plus an aggregate index.test.ts, run with Node’s built-in test runner via tsx --test and supertest for HTTP assertions. Individual middlewares perform careful input validation, throwing clear, actionable error messages for common mistakes (for example, catching the maxage vs maxAge and includeSubdomains vs includeSubDomains casing errors in the HSTS middleware). Strict typing and consistent naming run throughout.

API Design — The public API is deliberately minimal and ergonomic: app.use(helmet()) is enough to get a strong default posture, and every header can be turned off with false or customized with a typed options object using either camelCase or kebab-case directive keys. Each header is also exposed as a standalone middleware for granular use. Documentation is excellent, with a detailed README covering every header, an official docs site, and an FAQ.

Used by 32 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 3 weeks ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,916

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
90
Repo Health
77
Technical
61
Dependency
Built with
TypeScript 97%
Updated 6 days ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
JavaScript
99%
Other

ChartBrew

Analytics · Databases

4,063

Open-source reporting platform to build live dashboards from SQL, NoSQL, APIs, and SaaS tools with an AI assistant that creates charts from natural language.

View details
90
Repo Health
83
Technical
64
Dependency
Built with
JavaScript 99%
Updated 1 weeks ago
TypeScript
98%
AGPL 3.0

Checkmate

Analytics · Devops · Monitoring

10,895

Self-hosted uptime and infrastructure monitoring with multi-protocol checks, global geo-coverage, and beautiful real-time dashboards.

View details
90
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 98%
Updated 1 weeks ago
TypeScript
79%
Other

Directus

CMS · Low Code Platforms

37,987

Connect any SQL database and get instant REST and GraphQL APIs, a visual management Studio, and a native MCP server for AI agents — free for most organizations.

View details
92
Repo Health
82
Technical
76
Dependency
Built with
TypeScript 79%
Vue 19%
Updated 1 weeks ago
TypeScript
76%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,367

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
67
Dependency
Built with
TypeScript 76%
HTML 21%
Updated 5 days ago
TypeScript
95%
AGPL 3.0

HeyForm

Forms Surveys · No Code Platforms

8,984

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

View details
83
Repo Health
67
Technical
67
Dependency
Built with
TypeScript 95%
Updated 3 weeks ago
JavaScript
46%
MIT

Kutt

Analytics · Marketing

11,125

Self-hosted URL shortener with custom domains, per-link analytics, and zero build step required.

View details
74
Repo Health
62
Technical
72
Dependency
Built with
JavaScript 46%
Handlebars 24%
HTML 16%
Updated 4 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers