SecureStartKit
SecurityFeaturesPricingDocsBlogChangelog
Sign inBuy Now
Home/Free Tools/Next.js Security Headers Generator

Next.js Security Headers Generator

Configure security headers for your Next.js app and get copy-paste ready next.config.ts code. Choose a preset or customize each header individually.

Preset:

Strict-Transport-Security

Forces HTTPS for all future visits. Essential for production.

X-Frame-Options

Prevents clickjacking by controlling iframe embedding.

X-Content-Type-Options

Prevents MIME-type sniffing. Always enable this.

Referrer-Policy

Controls how much referrer info is sent with requests.

Permissions-Policy

Restrict browser features. Check features to block.

Content-Security-Policy

Controls which resources can load. Powerful but complex.

Edit directly or use Strict/Moderate presets as a starting point.

Generated next.config.ts

import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  async headers() {
    return [
      {
        source: '/(.*)',
        headers: [
          {
            key: 'Strict-Transport-Security',
            value: 'max-age=63072000; includeSubDomains; preload',
          },
          {
            key: 'X-Frame-Options',
            value: 'DENY',
          },
          {
            key: 'X-Content-Type-Options',
            value: 'nosniff',
          },
          {
            key: 'Referrer-Policy',
            value: 'strict-origin-when-cross-origin',
          },
          {
            key: 'Permissions-Policy',
            value: 'camera=(), microphone=(), geolocation=(), payment=(), usb=(), bluetooth=(), magnetometer=(), gyroscope=(), accelerometer=()',
          },
          {
            key: 'Content-Security-Policy',
            value: "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'",
          },
        ],
      },
    ]
  },
}

export default nextConfig

Add the headers() function to your existing next.config.ts, or use this as a starting point. Test your deployed headers at securityheaders.com.

Related Guides

Next.js Security Headers: From Zero Defaults to A+ [2026]

The full 7-header taxonomy: what each header does, where it lives in next.config.ts vs middleware, and the COOP/Stripe popup trap.

Next.js Security Checklist: 12 Steps [2026]

The full hardening checklist that surrounds these headers: CSP, env vars, RLS, webhook verification, rate limiting.

Backend-Only Data Access in Next.js + Supabase

Why headers alone are not enough. The architectural pattern that prevents the breach class headers cannot stop.

More Free Tools

๐Ÿ’ณ

Stripe Fee Calculator

Calculate Stripe fees for any payment method and currency.

๐Ÿ›ก๏ธ

RLS Policy Generator

Generate Supabase Row Level Security policies with templates.

๐Ÿ’ฐ

SaaS Pricing Calculator

Find your break-even price and suggested pricing tiers.

๐Ÿ–ผ๏ธ

OG Image Preview

Preview meta tags on Google, Twitter, LinkedIn, and more.

๐Ÿ”’

Security Checklist

30 essential security checks with scoring and progress tracking.

โ˜๏ธ

Tech Stack Costs

Compare hosting, database, and service costs at scale.

๐Ÿ”

Security Headers

Generate Next.js security headers config with copy-paste code.

๐Ÿ”‘

JWT Decoder

Decode and inspect JSON Web Tokens. View claims and expiry status.

โœ๏ธ

JWT Generator

Build and sign JWTs with HS256, HS384, or HS512 in your browser.

๐ŸŒ

CORS Config Generator

Generate CORS configuration for Next.js or Express with copy-paste code.

๐Ÿงช

JSON to Zod Converter

Paste JSON and get a typed Zod schema with format detection.

๐Ÿช

Stripe Webhook Verifier

Verify Stripe-Signature headers with your webhook secret in your browser.

๐Ÿ—๏ธ

API Key Generator

Generate cryptographically secure API keys, webhook secrets, and tokens in your browser.

Building a SaaS?

Skip months of boilerplate. SecureStartKit gives you auth, payments, email, and security best practices out of the box.

Get SecureStartKit