Documentation
Docs
Introduction
Getting Started
Tutorial: build an app
Core Concepts
Routing
Server-Side Rendering
Mimir, state management
Pages & Layouts
API Routes
Styling & Theming
Building & Deploying
API Reference
Guides
Recipes
FAQ (use cases)
helmet()
Harden every response with a set of sensible security headers. The single most valuable middleware for any public site, and the one to add first.
Use case
A browser will do risky things unless a response tells it not to: sniff a response's content type, render
your page inside a hostile <iframe>, leak the full referrer to third parties, or load scripts from
anywhere. helmet sets the headers that turn those defaults off, in one line, for the whole app.
How it works
It runs on every response and adds the standard hardening headers before next():
X-Content-Type-Options: nosniff, stop MIME sniffing.X-Frame-Options: DENY, block clickjacking via framing.X-XSS-Protection: 0, disable the legacy, buggy auditor (CSP is the real defence).Referrer-Policy: strict-origin-when-cross-origin, trim the referrer cross-site.Content-Security-Policy: default-src 'self', only load your own assets by default.Strict-Transport-Security(HSTS) , force HTTPS on repeat visits.- A restrictive
Permissions-Policy, deny camera, microphone, geolocation, payment.
Configuration
| Option | Default | Notes |
|---|---|---|
frameguard | "DENY" | X-Frame-Options value ("SAMEORIGIN" to allow same-origin framing). |
contentSecurityPolicy | "default-src 'self'" | A CSP string, or false to omit the header. |
hsts.maxAge | 31536000 | HSTS max-age (seconds); includeSubDomains is always added. |
permissionsPolicy | camera=(), microphone=(), geolocation=(), payment=() | The Permissions-Policy value. |
Example
Notes
A rune docs or marketing site that loads only its own assets is happy with the default CSP. If you embed third-party scripts, fonts, or analytics, widen the CSP (add the specific sources) rather than disabling it with
contentSecurityPolicy: false.
Next: cors.