mediumFrontend

What is next.config.js in Next.js and what are common configurations?

596 views
01

Understand the problem

The framework configuration file.

nextjsnext-configconfigurationbuild
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

A typical next.config
// next.config.ts
import type { NextConfig } from 'next';
const config: NextConfig = {
  output: 'standalone',
  images: { remotePatterns: [{ protocol: 'https', hostname: 'cdn.example.com' }] },
  async redirects() { return [{ source: '/old', destination: '/new', permanent: true }]; },
  async headers() { return [{ source: '/(.*)', headers: [{ key: 'X-Frame-Options', value: 'DENY' }] }]; },
  experimental: { optimizePackageImports: ['lodash'] },
};
export default config;
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.