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
SecureStartKit

The security-first Next.js SaaS template. Auth, payments, and everything you need to launch - with backend-only data access, Zod validation on every input, and built-in optimization for AI coding agents.

Summarize with AI

Product

  • Security
  • Features
  • Pricing
  • FAQ
  • Docs
  • About

Use Cases

  • For Indie Hackers
  • For Solo Developers
  • Fintech SaaS
  • Internal Tools
  • Healthtech SaaS

Free Tools

  • All Tools
  • RLS Policy Generator
  • Security Checklist
  • Security Headers
  • JWT Decoder
  • JWT Generator
  • CORS Config Generator
  • JSON to Zod Converter
  • API Key Generator
  • Stripe Webhook Verifier
  • Stripe Fee Calculator
  • SaaS Pricing Calculator
  • Tech Stack Costs
  • OG Image Preview

Compare

  • All comparisons
  • vs ShipFast
  • vs Makerkit
  • vs Supastarter
  • vs Divjoy
  • vs Nextbase
  • One-time vs subscription

Resources

  • Blog
  • Glossary
  • Security Patterns
  • Changelog
  • Contact
  • Privacy
  • Terms

More from the same maker

  • AppScreenshotStudio
  • QueryScope
  • BookIllustrationAI
  • MyCVCraft
  • StyleMyFade

ยฉ 2026 SecureStartKit. All rights reserved.

Built with SecureStartKit