Gone are the days of manually wiring up half a dozen link tags in your HTML <head>. Next.js App Router introduced zero-config file conventions that handle icon generation, sizing, and HTTP caching automatically.

The App Router File Conventions

By placing specific filenames inside your project's app/ root directory, Next.js will automatically detect them and inject the correct <link> tags into the compiled HTML head with immutable cache headers.

• app/icon.svg — Dynamic vector favicon supporting dark/light mode

• app/apple-icon.png — High-resolution touch icon (180x180 px)

• app/favicon.ico — Legacy 32x32 fallback

• app/opengraph-image.png — Social sharing card preview (1200x630 px)

Dynamic Icon Generation via ImageResponse

If you prefer generating icons dynamically based on user avatars or brand configuration, you can use Next.js's ImageResponse JSX runtime inside app/icon.tsx.

import { ImageResponse } from 'next/og';

export const runtime = 'edge';
export const size = { width: 32, height: 32 };
export const contentType = 'image/png';

export default function Icon() {
  return new ImageResponse(
    (
      <div
        style={{
          fontSize: 20,
          background: 'linear-gradient(135deg, #3b82f6, #1d4ed8)',
          width: '100%',
          height: '100%',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          color: 'white',
          borderRadius: 8,
        }}
      >
        ✦
      </div>
    ),
    { ...size }
  );
}