Declare supported Next.js options with TypeScript checking.
Type-safe project configuration
Next.js 16+ · Interface
NextConfig is the TypeScript type for a Next.js configuration object. Export a root-level configuration module by default so Next.js can apply its server- and build-time options.
NextConfig is the TypeScript type for the object exported from a Next.js configuration file. Define the configuration at the project root and export it as the default export; Next.js reads it during server and build phases, while the file is excluded from the browser bundle.
const nextConfig: NextConfig = { /* options */ }
export default nextConfigA NextConfig configuration object exported as the default export of the project's Next.js configuration module.
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
reactCompiler: true,
}
export default nextConfigThis typed configuration enables the stable React Compiler option in a Next.js 16 application.
Type-safe project configuration
Build and server customization
Next.js 16 feature adoption
NextConfig is the type used to describe the configuration object exported by a Next.js config file. The file belongs at the project root and uses a default export.
Follow-up: How would you avoid exposing a secret placed in the config? Keep it server-side: configuration is consumed by the server and build phases and is not included in the browser build, but client-exposed values still require separate care.
A Next.js configuration file is a regular Node.js module, so it can contain module syntax and executable configuration logic. It is not parsed as a JSON document.
Follow-up: What practical benefit does this provide? It permits typed imports, conditional values, and other Node-side composition that JSON cannot express.
Export the configuration object as the file's default export, typically from a root-level next.config.ts or next.config.js file. Next.js then applies the options during server and build phases.
Follow-up: Which current Next.js 16 option could be enabled in this object? The documentation's Next.js 16 guidance shows top-level options such as turbopack, while reactCompiler is also promoted to stable.
turbopackreactCompilernext.config.tsnext.config.js