Skip to content
pubscout

shelf_helmet

2.3.0, released 3 years ago by jxstxn.dev

Secure Dart Shelf and Dart Frog apps by setting HTTP security headers

WASM-ready
$ flutter pub add shelf_helmet
Source repository

What it does

Port of the NodeJS helmet package to Dart, providing middleware for Shelf and Dart Frog that automatically sets various HTTP security headers like Content-Security-Policy, X-Frame-Options, and Strict-Transport-Security.

AI-written summary of version 2.3.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a backend or web application using Dart Shelf or Dart Frog.
  • You need to protect your web endpoints with standard HTTP security headers.

Skip it when

  • Your application does not use Dart Shelf, Dart Frog, or compatible middleware frameworks.
  • You prefer to manually construct and assign all security response headers yourself.

Strengths

  • Wraps 13 individual security header middlewares into a single easy-to-use call.
  • Highly configurable options for individual headers and policies.
  • Out-of-the-box support for popular frameworks like Shelf, Dart Frog, and Pharaoh.

Weaknesses

  • Not a silver bullet for overall application security.
  • Requires careful tuning of options like CSP to avoid breaking legitimate web page resources.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

Add the package via `dart pub add shelf_helmet` and integrate it into your middleware pipeline.

import 'package:shelf_helmet/shelf_helmet.dart';

var handler = const Pipeline()
    .addMiddleware(helmet())
    .addMiddleware(logRequests())
    .addHandler(_echoRequest);

Alternatives

Packages that do the same job and could replace shelf_helmet.

Works with

Packages commonly used together with shelf_helmet: ones it builds on, ones built on it, and its own family.