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.

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.

Building a SaaS?

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

Get SecureStartKit