Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including koa-helmet with all npm packages installed. Try it out:

var koaHelmet = require("koa-helmet")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

koa-helmet v3.3.0

Security header middleware collection for koa


Version Build Status Coverage Status Dependency Status Standard - JavaScript Style Guide Downloads

koa-helmet is a wrapper for helmet to work with koa. It provides important security headers to make your app more secure by default.


yarn add koa-helmet

or via npm:

npm install koa-helmet --save


Usage is the same as helmet

Helmet offers 11 security middleware functions:

contentSecurityPolicy for setting Content Security Policy
dnsPrefetchControl controls browser DNS prefetching
frameguard to prevent clickjacking
hidePoweredBy to remove the X-Powered-By header
hpkp for HTTP Public Key Pinning
hsts for HTTP Strict Transport Security
ieNoOpen sets X-Download-Options for IE8+
noCache to disable client-side caching
noSniff to keep clients from sniffing the MIME type
referrerPolicy to hide the Referer header
xssFilter adds some small XSS protections

You can see more in the documentation.


In order to work well with the helmet HSTS module, koa-helmet will augment this.request to include a secure boolean to determine if the request is over HTTPS.


const Koa = require('koa')
const helmet = require('koa-helmet')
const app = new Koa()


app.use((ctx) => {
  ctx.body = 'Hello World'



To run the tests, simply run

yarn test


  • koa-helmet >=2.x (master branch) supports koa 2.x
  • koa-helmet 1.x (koa-1 branch) supports koa 0.x and koa 1.x


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free