Configuration files in Next.js

From the Next.js cheat sheet · Project Setup & Structure · verified Jul 2026

Configuration files

javascript
// next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  // Enable React Strict Mode
  reactStrictMode: true,
  
  // Configure remote image hosts (domains is deprecated)
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: '**.example.com',
      },
    ],
  },
  
  // Environment variables
  env: {
    API_URL: process.env.API_URL,
  },
  
  // Redirects
  async redirects() {
    return [
      {
        source: '/old-path',
        destination: '/new-path',
        permanent: true,
      },
    ]
  },
}

export default nextConfig
💡 next.config.ts (or .js) - typed via NextConfig
⚡ TypeScript config is auto-generated
📌 .env.local for environment variables
🟢 proxy.ts (was middleware.ts) runs before requests

More Next.js tasks

Back to the full Next.js cheat sheet