Next.js config generator

Pick what your deployment needs. The file writes itself.

Sensible defaults with the platform doing the packaging.Standalone output, compression left to the proxy.Standalone pods sharing one Redis-backed ISR cache.Plain HTML for object storage or GitHub Pages.Node behind a reverse proxy that owns compression and TLS.Workspace packages traced and transpiled correctly.Assets on an edge origin with long-lived caching.Full header set, tight image hosts, nothing leaked.Every safe compiler and bundle optimization switched on.Strict mode and nothing else.

React Strict Mode

reactStrictMode

Double-invoke render and effects in development to surface unsafe code.

Catches unsafe lifecycles, missing effect cleanups and impure renders before they reach production.

Recommended

Build output mode

output

Package the build as a standalone server or as a fully static export.

standalone traces only the files the server actually needs, so a Docker image drops from hundreds of megabytes to tens. export emits plain HTML you can host on any static bucket.

Build directory

distDir

Rename the folder the build is written to.

Useful when another tool in the repo already owns `.next`, or when a host expects a specific folder name.

Base path

basePath

Serve the whole app under a sub-path such as /docs.

Lets you host the app under a path on a shared domain, behind an nginx location block or an ingress rule.

Asset prefix

assetPrefix

Serve static assets from a CDN origin instead of your app domain.

Moves JS, CSS and font delivery to a CDN edge, cutting latency and taking load off the origin server.

Trailing slash

trailingSlash

Force every URL to end with a slash.

Most static hosts resolve `/about/` to `/about/index.html`, so a static export is far more predictable with this on.

Page extensions

pageExtensions

Restrict or extend which file extensions become routes.

Needed to route `.mdx` files, or to co-locate tests and stories next to pages without turning them into routes.

Build-time environment variables

env

Inline values into the bundle at build time.

Handy for values that are genuinely public and fixed at build time, such as a release tag or a build id.

Server external packages

serverExternalPackagesv15.0

Keep specific server packages out of the bundler.

Packages with native bindings or dynamic requires break when bundled. Listing them keeps them as runtime requires.

Transpile packages

transpilePackages

Compile untranspiled dependencies from your monorepo or npm.

Workspace packages that ship raw TypeScript or modern syntax need compiling before they can run in the app.

File tracing root

outputFileTracingRoot

Point tracing at the monorepo root so shared files are included.

In a monorepo the app folder is not the dependency root, so tracing misses hoisted packages and the standalone build crashes at runtime.

Clean build directory

cleanDistDir

Wipe the build folder before each build.

Explicitly stating it documents intent in a repo where CI reuses the same workspace between runs.

Allowed remote image hosts

images.remotePatterns

Whitelist the hosts next/image is allowed to optimize from.

next/image refuses to optimize any host you have not listed, which stops strangers from using your optimizer as a free image proxy.

Image domains (legacy)

images.domainsdeprecated

The old hostname whitelist, kept for migrations only.

Only useful while migrating an older codebase that still relies on it.

Output formats

images.formats

Modern formats the optimizer may serve.

AVIF typically lands 20 to 30 percent smaller than WebP at the same quality, which directly helps LCP on image-led pages.

Device breakpoints

images.deviceSizes

Widths generated for images that fill the viewport.

Trimming the default list to the breakpoints your layout actually uses cuts the number of variants generated and cached.

Fixed-size widths

images.imageSizes

Widths generated for images with a known display size.

Match these to your real thumbnail and avatar sizes so small images never fall through to a device-size variant.

Allowed quality values

images.qualitiesv16.0

Restrict which `quality` values callers may request.

Without a list, any integer from 1 to 100 creates a separate cache entry, so one popular image can occupy a hundred slots.

Minimum cache lifetime

images.minimumCacheTTL

Floor for how long an optimized image is cached, in seconds.

Upstream hosts often send a short max-age. Raising the floor stops your optimizer re-fetching and re-encoding the same file all day.

Disable image optimization

images.unoptimized

Serve every image exactly as authored.

Required for a static export, and reasonable when a CDN such as Cloudinary or imgix already handles resizing.

Allow remote SVG

images.dangerouslyAllowSVG

Permit SVG files through the image optimizer.

Needed when logos or icons come from a CMS as SVG and must go through next/image.

Image content disposition

images.contentDispositionType

How the browser is told to handle optimized image responses.

Setting attachment stops a directly opened SVG from executing in the origin's context.

Custom image loader

images.loader

Hand URL building to an external image service.

Lets an existing image CDN do the resizing so the Next.js server never touches image bytes.

Loader file path

images.loaderFile

Module that exports the custom loader function.

Required whenever the loader is set to custom.

Security response headers

headers

Send hardening headers on every route.

These headers close off whole classes of attack at the edge, and security scanners check for them before anything else.

CORS route pattern

headers

Which routes the cross-origin rules apply to.

Scoping CORS to your API routes keeps the rest of the site unaffected.

Allowed origins

headers

Origins permitted to call your API from a browser.

An explicit origin list is the difference between a private API and one any site can call with a visitor's session.

Allowed methods

headers

HTTP methods accepted from other origins.

Preflight requests fail unless the method is listed, and listing only what you use keeps the surface small.

Allowed request headers

headers

Custom headers other origins may send.

Any header beyond the browser-safe list must be named here or the preflight fails.

Allow credentials

headers

Let cross-origin requests carry cookies.

Required when a separate front-end domain authenticates against your API using cookies.

Crawler control header

headers

Send X-Robots-Tag to keep an environment out of search results.

A header applies to every response including PDFs and JSON, which a robots.txt file and a meta tag cannot cover.

Static asset caching

headers

Long-lived cache rules for your own asset folders.

Files in `public/` are not fingerprinted, so they get a short cache by default and are re-fetched far more often than they need to be.

Hide X-Powered-By

poweredByHeader

Stop advertising the framework in every response.

Removes a free hint that tells an attacker exactly which framework and exploit set to try.

Disable ETag generation

generateEtags

Skip ETags when a proxy or CDN already handles validation.

Behind a CDN that generates its own validators, the origin ETag is redundant work on every response.

Disable built-in compression

compress

Hand gzip and brotli to nginx or the CDN instead.

Compressing twice wastes CPU. A reverse proxy or CDN usually does it faster and supports brotli properly.

Script crossOrigin attribute

crossOrigin

Attribute added to script tags Next.js injects.

Needed when assets are served from a different origin and you want useful error messages instead of an opaque script error.

Disable HTTP keep-alive

httpAgentOptions.keepAlive

Turn off connection reuse for server-side fetches.

Some load balancers and service meshes drop pooled connections, which surfaces as intermittent socket hang-ups.

Redirects

redirects

Send one path to another with a real HTTP status.

The correct way to preserve ranking and inbound links after a URL change, and to retire old marketing paths.

Rewrites

rewrites

Proxy a path to another destination without changing the URL.

Lets you put a Next.js app in front of an existing backend, or migrate route by route while the URLs stay stable.

Skip trailing slash redirect

skipTrailingSlashRedirect

Stop Next.js redirecting between slashed and unslashed URLs.

Necessary when middleware or an upstream proxy already normalizes URLs and you want to avoid a redirect loop.

Skip middleware URL normalize

skipMiddlewareUrlNormalize

Give middleware the raw, unnormalized URL.

Needed when middleware has to inspect the exact incoming URL, including internal data-fetch paths.

Strip console calls

compiler.removeConsole

Remove console output from production builds.

Debug logs shrink the bundle slightly and, more importantly, stop internal state from being printed in a visitor's console.

Strip test attributes

compiler.reactRemoveProperties

Drop data-testid props from production output.

Test hooks add DOM weight and quietly describe your component structure to anyone reading the markup.

styled-components support

compiler.styledComponents

Enable the SWC transform for styled-components.

Gives correct server-side rendering and readable class names without a Babel plugin, which keeps SWC's build speed.

Optimize package imports

experimental.optimizePackageImports

Tree-shake barrel-file packages like icon libraries.

Barrel files make one icon import pull in the entire library. This rewrites those imports to direct module paths.

Inline critical CSS

experimental.optimizeCss

Inline above-the-fold CSS and defer the rest.

Removes a render-blocking stylesheet request, which is often the last thing standing between a page and a perfect Lighthouse score.

React Compiler

experimental.reactCompilerv15.0

Let the compiler insert memoization for you.

Removes most hand-written useMemo and useCallback while keeping, and usually improving, render performance.

Partial prerendering

experimental.ppr

Serve a static shell and stream the dynamic parts in.

Gives a static first byte on pages that also need per-user data, which normally forces the whole route to be dynamic.

Server action body limit

experimental.serverActions.bodySizeLimit

Maximum payload a server action will accept.

The default 1mb rejects most direct file uploads through a server action.

Static generation timeout

staticPageGenerationTimeout

Seconds a single page may take to prerender.

Large catalogue builds that hit slow upstream APIs exceed the 60 second default and fail the whole build.

CDN stale-while-revalidate

expireTime

Seconds a CDN may serve stale ISR content while revalidating.

Lets the CDN answer instantly from cache while your origin regenerates the page in the background.

Custom cache handler

cacheHandler

Share the ISR cache across instances with Redis.

Without it, every container keeps its own in-memory ISR cache, so revalidation on one pod leaves the others stale.

In-memory cache size

cacheMaxMemorySize

Bytes of ISR cache kept in process memory. Zero disables it.

Set it to zero alongside a shared cache handler so a pod never serves a stale copy it is holding locally.

Reduce build memory

experimental.webpackMemoryOptimizations

Trade some build speed for lower peak memory.

Fixes out-of-memory build failures in CI runners and containers with tight memory limits.

Turbopack root

turbopack.root

Tell Turbopack where the workspace root is.

In a monorepo Turbopack can infer the wrong root from a stray lockfile and then resolve modules from the wrong place.

Ignore TypeScript errors

typescript.ignoreBuildErrors

Let the build finish even with type errors.

An emergency hatch for shipping a hotfix while a dependency's types are broken.

Skip ESLint during build

eslint.ignoreDuringBuilds

Do not run linting as part of next build.

Reasonable when a separate CI step already lints, since running it twice just slows the build down.

ESLint directories

eslint.dirs

Limit which folders are linted during the build.

Keeps linting off generated code, fixtures and scripts that will never satisfy the app's rules.

Production source maps

productionBrowserSourceMaps

Ship browser source maps with the production build.

Turns minified production stack traces into readable ones, which most error monitoring depends on.

Log full fetch URLs

logging.fetches.fullUrl

Print complete URLs for server-side fetches in development.

Makes it obvious which fetches are hitting the cache and which are going out again, which is otherwise guesswork.

Next.js config generator

Generate a next.config file that fits where you deploy

This Next.js config generator writes your next.config.ts or next.config.js while you click. Start from a preset for Vercel, Docker, Kubernetes, nginx or a static export, switch on only the settings your project needs, and the finished file builds itself beside the options. Each option says when to use it and when to leave it off, and an Issues tab flags combinations that fail, such as rewrites inside a static export or an image host left wide open. It is for developers who ship Next.js apps and would rather not copy a config from an old repo and hope it still fits.

  • Free, no signup
  • Runs in your browser
  • TypeScript or JavaScript
  • ESM or CommonJS
options in 8 groups
60
deployment presets
10
built-in checks
17
runs in your browser
100%
next.config.ts
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  reactStrictMode: true,
  output: "standalone",
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "res.cloudinary.com",
        pathname: "/**",
      },
    ],
  },
  poweredByHeader: false,
  compress: false,
};

export default nextConfig;
Real output from the Docker preset, trimmed. The full file also carries the security headers.

01Features

Everything you need to get a config right the first time

Built for the part of Next.js setup that is easy to get subtly wrong: deployment settings, image hosts, headers and caching.

Checks while you click

Every toggle is checked against the others as you go. A static export with rewrites, a wildcard CORS origin with credentials, an open image host: each shows up with a clear label and a button that jumps to the option involved.

ConflictStatic export cannot use rewrites

Guidance on every option

All 60 options carry four short answers: why you would use it, when not to, what it does in production, and the mistake people usually make.

Ten starting points

Pick the preset closest to your setup, then adjust. You never have to start from an empty file.

  • Vercel production
  • Docker
  • Kubernetes
  • Static export
  • Self hosted behind nginx
  • Monorepo
  • CDN optimized
  • Security hardened
  • Maximum performance
  • Minimal

TypeScript or JavaScript

Get next.config.ts, or JavaScript as ESM (next.config.mjs) or CommonJS (next.config.js). The file name and import style follow your choice.

Search that reads intent

Type docker, cors or cache and the list narrows by option name, description and related terms, not just exact key names.

Real inputs for real settings

Image hosts, redirects, rewrites, headers and CORS origins use rows and dropdowns, so you choose a protocol instead of remembering how to spell it.

Your choices stay with you

Everything runs in your browser. Nothing you toggle or type is uploaded, logged or saved when you close the tab.

Copy or download

Copy the file to your clipboard or download it under the right name, ready for the project root.

02Compared

Why not copy an old config, or write it by hand?

All three work. They differ in how many surprises are left for build time.

Fits your deployment

Old configFits the last app, not necessarily this one.

From the docsFits, if you read every page that applies.

This generatorStarts from a preset for your target.

Catches conflicts

Old configFound at build time or in production.

From the docsFound when you happen to notice.

This generatorFlagged the moment you toggle.

Explains each option

Old configRarely. The comments got lost on the way.

From the docsThoroughly, one page per option.

This generatorWhy, when not to, impact and a common mistake, on every option.

What you need

Old configAccess to an old project.

From the docsA lot of reading time.

This generatorA browser tab. Nothing to install.

Best for

Old configSmall tweaks you already understand.

From the docsOptions the generator does not cover.

This generatorA first working file that avoids the known traps.

03How to use

From a blank page to a finished file in six steps

On a wide screen the options sit beside the live file. On a phone you switch between Configure and Output. Either way there is nothing to install and nothing to save.

  1. Pick a starting point

    Choose the preset closest to your deployment: Vercel production, Docker, Kubernetes, static export, nginx, monorepo, CDN, security hardened, maximum performance or minimal. Prefer a blank slate? Only React Strict Mode is on.

    The file on the right fills in at once

  2. Narrow the list

    Filter by target (Vercel, Docker, Kubernetes, nginx, Redis, CDN, static export, monorepo) or search for a word like cors, cache or docker. Search reads option names, descriptions and related terms.

    Only options that matter for that target stay

  3. Switch on what you need

    Each toggle opens its own fields right underneath: a dropdown, a number, a tag box or a list of rows. Nothing opens in another page or a popup.

    The matching keys appear in the file

  4. Add your own values

    Type your image hosts, allowed CORS origins, redirects and headers. Protocols come from a dropdown, and you can add as many hosts or rules as you need. The question mark on any row gives the short guidance.

    Empty or duplicate rows get flagged

  5. Read the Issues tab

    Conflicts, things worth checking and notes are listed with a button that jumps to the option behind each one. Fix them here instead of at build time.

    A red count when something will break

  6. Copy or download

    Pick TypeScript or JavaScript, then ESM or CommonJS if you chose JavaScript. The file is named next.config.ts, next.config.mjs or next.config.js to match. Put it next to package.json and run your build.

    A file that is ready for the project root

04Checks

What the Issues tab catches before your build does

These run on every change, and the labels match the tab. Conflict means the build or the browser will reject it. Check this means it works but is probably a mistake. Note is worth knowing.

  • Conflict

    when output is "export" and rewrites, redirects, response headers, a cache handler or an expire time are on

    A static export ships no server, so none of these can run. Move them to the host that serves the files.

  • Conflict

    when output is "export" and image optimization is still on

    The optimizer is a server route, so images fail. Turn it off or point to an image CDN loader.

  • Conflict

    when a wildcard CORS origin is paired with credentials

    Browsers refuse that pairing, so every request that carries cookies fails.

  • Conflict

    when a bare * is allowed as an image host

    Anyone can push images through your optimizer. A pattern like *.example.com is a lighter Check this.

  • Conflict

    when SVG images are allowed without the attachment disposition

    An SVG can carry script, which becomes stored XSS on your own domain.

  • Check this

    when images.domains is used, or sits next to remotePatterns

    The old list only matches hostnames and is deprecated. Move every host into remotePatterns.

  • Check this

    when a custom cache handler is set without the in-memory cache size set

    Each pod keeps a local copy, so a revalidated page can look stale on some of them.

  • Check this

    when an X-Robots-Tag noindex header is on

    It hides every response from search engines. Keep it for staging only.

  • Note

    when more than one CORS origin is listed

    A header carries one origin, so the file emits the first and flags the rest. Echo the match from middleware.

05Real setups

Four setups, and the file each one produces

The snippets are real generator output, trimmed for space. Each one starts from a preset and changes only what the project needs.

Static export preset

Docs site on a storage bucket

No server logic at all, hosted from plain object storage.

  • output: export
  • images.unoptimized
  • trailingSlash
const nextConfig: NextConfig = {
  reactStrictMode: true,
  output: "export",
  trailingSlash: true,
  images: {
    unoptimized: true,
  },
};

Plain HTML the bucket can serve, with URLs shaped the way static hosts expect.

Kubernetes preset

Admin tool on Kubernetes

Several pods behind a load balancer sharing one Redis instance.

  • output: standalone
  • cacheHandler
  • cacheMaxMemorySize: 0
  output: "standalone",
  poweredByHeader: false,
  generateEtags: false,
  compress: false,
  cacheHandler: path.resolve("./cache-handler.mjs"),
  cacheMaxMemorySize: 0,

A small image, and every pod reads ISR pages from the same cache.

Vercel production preset

Dashboard with remote images on Vercel

Avatars and attachments served from Cloudinary, no container step.

  • images.remotePatterns
  • images.formats
  • poweredByHeader
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "res.cloudinary.com",
        pathname: "/**",
      },
    ],
    formats: ["image/avif", "image/webp"],
  },

One allowed image host, modern formats, and no framework header leaking out.

Security hardened preset

API for one known front end

A REST API that only one origin may call from a browser.

  • headers()
  • corsOrigins
  • corsMethods
      {
        source: "/api/:path*",
        headers: [
          {
            key: "Access-Control-Allow-Origin",
            value: "https://app.example.com",
          },
          {
            key: "Access-Control-Allow-Methods",
            value: "GET, POST, OPTIONS",
          },
        ],
      },

CORS scoped to the API route, written into a single generated headers() block.

06Good to know

Limits and version notes, stated plainly

A config tool is only useful if you know where it stops. The official next.config reference stays the source of truth.

It covers the options most projects touch.

That is 60 options in eight groups, not every key in the reference. For anything else, add it by hand and keep the official reference open.

  • Core 2
  • Build and output 9
  • Images 12
  • Security and CORS 11
  • Routing 7
  • Performance 10
  • Developer experience 5
  • Platform 4

Keys move between Next.js releases.

next.config.ts needs Next.js 15 or newer, and options get renamed or promoted between majors. Next.js 16, for example, moved turbopack and reactCompiler out of experimental. Check any experimental key against the docs for the version you run.

A generated file is a starting point.

The checks catch known traps, not mistakes that depend on your project, like which image hosts are really yours. Read the Issues tab, then run your build once before you deploy.

07FAQ

Questions developers ask before they trust a generated config

Straight answers about accuracy, the static export error, image hosts, CORS and privacy.

Do I need to already know Next.js config options to use this?

No. Presets cover the common deployment targets, and every option comes with a short description plus a Learn more explaining what it's for. You can build a working config without knowing what outputFileTracingRoot means going in.

Is the file I copy out actually production-ready?

It's syntactically complete and cross-checked for conflicts, but it still reflects choices only you can make, like which image hosts are really yours or which origins should be trusted. Treat the Issues tab as a second pair of eyes, not a substitute for reading what you turned on.

Why does it say output: "export" conflicts with my rewrites?

A static export has no Next.js server running when someone visits the site, and rewrites are resolved by that server. The fix isn't in next.config at all, it's moving the rule to whatever host is actually serving the static files.

What's the real difference between images.domains and images.remotePatterns?

domains only checks the hostname. remotePatterns also checks protocol, port, and path, which is the part that actually stops a stranger from optimizing arbitrary images through your server. The old key still works but is on its way out.

Can I get a next.config.ts file, or only JavaScript?

Both. next.config.ts needs Next.js 15 or newer and gives you typed options. It uses export default, but imports inside a .ts config are resolved the CommonJS way, so a package that ships only as ESM can fail to load there. If that happens, use next.config.mjs. JavaScript output lets you choose ESM (next.config.mjs) or CommonJS (next.config.js).

How does this handle CORS without me writing a headers() function by hand?

Origins, methods, allowed headers, and the credentials flag all merge into a single generated headers() block, grouped by the route pattern you set. If you list more than one allowed origin, it flags that you'll need middleware to echo back the matching one, since a header can only carry one value.

Do I actually need a custom cache handler?

Only once more than one instance of your app is serving the same pages. A single server or a Vercel deployment already keeps this consistent on its own. On Kubernetes or behind Docker replicas, each container otherwise holds its own copy of the ISR cache.

Does this tool store or send my configuration anywhere?

No. Every option you toggle stays in your browser tab and is used only to render the file on screen. Nothing is uploaded, logged, or saved once you close the page.

Where does next.config.js go, and is it required?

It sits in the root of your project, next to package.json. It is optional: a Next.js app runs on its defaults without one, and you add the file when you need to change something such as images, headers or the build output.

Do I need to restart after changing next.config?

Yes. The file is read when Next.js starts and when you build, so a change only takes effect after a restart or a new build. The dev server usually restarts itself when it notices the file changed.

Is the generator free, and do I need an account?

It is free and needs no signup. Open the page, build the file, then copy or download it.

UntangleTools Logo
UntangleTools Logo
UntangleTools Logo