next.config.js

The root configuration file controlling build and runtime behavior.

Since All versions; .ts support Next 15 Spec ↗

Syntax

const nextConfig = { ... }; export default nextConfig

Parameters

NameTypeRequiredDescription
nextConfig NextConfig Yes Options like `images`, `redirects`, `rewrites`, `headers`, `experimental`, `output`, `env`.

Returns

NextConfig — The configuration object Next reads at build/start.

Examples

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

const nextConfig: NextConfig = {
  reactStrictMode: true,
  images: {
    remotePatterns: [
      { protocol: 'https', hostname: 'cdn.example.com' },
    ],
  },
}

export default nextConfig
// Async config with redirects
const nextConfig = {
  async redirects() {
    return [{ source: '/old', destination: '/new', permanent: true }]
  },
}
module.exports = nextConfig

Notes

Lives at the project root as `next.config.js`, `.mjs`, or `.ts` (TypeScript supported). Several keys (`redirects`, `rewrites`, `headers`) are async functions. Changes require a dev server restart. Use the `NextConfig` type for autocompletion.

See also