BACK TO DIRECTORY
settingintermediate
Next.js Optimized
A battle-tested Next.js configuration for production applications. Includes optimal image configuration with remote patterns, security headers (CSP, HSTS, X-Frame-Options), redirects and rewrites patterns, bundle analyzer integration, and edge runtime configuration. Based on configurations used by high-traffic production Next.js applications.
534 STARS
7.9k DOWNLOADS
claude-templates
nextjsproductionoptimizationsecurityconfig
CONFIGURATION
typescript
1// next.config.ts2import type { NextConfig } from "next";34const nextConfig: NextConfig = {5 // Performance6 reactStrictMode: true,7 poweredByHeader: false,8 compress: true,910 // Images11 images: {12 formats: ["image/avif", "image/webp"],13 remotePatterns: [14 {15 protocol: "https",16 hostname: "**.example.com",17 },18 ],19 minimumCacheTTL: 60 * 60 * 24, // 24 hours20 },2122 // Security Headers23 async headers() {24 return [25 {26 source: "/(.*)",27 headers: [28 {29 key: "X-Frame-Options",30 value: "DENY",31 },32 {33 key: "X-Content-Type-Options",34 value: "nosniff",35 },36 {37 key: "Referrer-Policy",38 value: "strict-origin-when-cross-origin",39 },40 {41 key: "Permissions-Policy",42 value: "camera=(), microphone=(), geolocation=()",43 },44 {45 key: "Strict-Transport-Security",46 value: "max-age=31536000; includeSubDomains",47 },48 ],49 },50 ];51 },5253 // Redirects54 async redirects() {55 return [56 {57 source: "/old-path",58 destination: "/new-path",59 permanent: true,60 },61 ];62 },6364 // Experimental features65 experimental: {66 typedRoutes: true,67 },68};6970export default nextConfig;