Insights · Nov 5, 2026 · 4 min read · FAQ

Next.js images: the next/image settings that actually matter

Using next/image is only the start. Reserved space, the sizes prop, how the hero loads and a tight images config decide speed and layout shift.

NEXT.JS IMAGESWithout the layout shift SELLWRIGHT

Many Next.js teams send every image through next/image, yet PageSpeed Insights still flags a slow Largest Contentful Paint, layout shift and oversized files. The component does the resizing and format work, but it needs a few props and settings to know what each image is for. These are the ones we check first.

Why does next/image still shift the layout?

Because the browser can only reserve space when it knows the image's shape. The width and height props give Next.js the file's intrinsic size, which sets the aspect ratio; CSS decides the size on screen. Both are required unless the image is statically imported or uses fill.

  • Static imports, such as import photo from './photo.jpg', supply the width, height and blur data automatically.
  • Remote and CMS images need their real dimensions passed in. Browsers reserve space from those numbers, then switch to the file's own proportions once it loads, so a guessed ratio still moves the page.
  • With fill, the image is absolutely positioned and takes up no space, so its positioned parent needs a size of its own, such as a fixed height or a CSS aspect-ratio.
  • If style sets the width, also set height: 'auto'.

Why are the image files still too large?

Usually a missing sizes prop. It tells the browser how wide the image displays at each breakpoint; without it, the browser assumes the full viewport width. It also changes the srcset Next.js generates:

  • A width and no sizes: only 1x and 2x versions. Fine for logos and avatars, not for images that CSS stretches.
  • fill and no sizes: widths from deviceSizes, as if the image spanned the whole screen.
  • With sizes: a full range of widths, so the browser can pick the smallest file that fits.

The costly case is a card grid: three cards in a row, each using fill without sizes, and every card downloads a file wide enough for the full screen. sizes="(max-width: 768px) 100vw, 33vw" describes the real layout.

In your browser's developer tools, filter the Network panel by images and compare the w= value in each /_next/image URL with the width the image takes on screen.

How should the hero image load?

Immediately. next/image lazy-loads by default, which suits images further down the page, but web.dev warns that lazy-loading the LCP image always adds delay. In Next.js 16 the old priority prop is deprecated in favour of preload, which adds a <link> for the image to the page head.

The docs say that in most cases loading="eager" or fetchPriority="high" is a better choice than preload. We set both on the one hero image, because fetchPriority raises the download priority but leaves the default lazy loading in place. Keep preload for an image the browser would discover late, never alongside loading or fetchPriority, and skip it when the LCP image changes with screen size.

// app/hero.tsx
import Image from 'next/image'
import heroPhoto from './hero.jpg' // width and height come from the file

export function Hero() {
  return (
    <Image
      src={heroPhoto}
      alt="Team reviewing a launch plan"
      sizes="100vw"
      loading="eager"
      fetchPriority="high"
      style={{ width: '100%', height: 'auto' }}
    />
  )
}

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

const nextConfig: NextConfig = {
  images: {
    remotePatterns: [
      { protocol: 'https', hostname: 'cdn.example.com', port: '', pathname: '/uploads/**', search: '' },
    ],
    qualities: [60, 75],
  },
}

export default nextConfig

How do you allow external images safely?

List only the sources you use in images.remotePatterns, as narrowly as you can. A URL that does not match on protocol, host, port, path or query string gets a 400 response. Leaving out the protocol, port, path or search field allows any value there, which the docs advise against. The older domains setting has been deprecated since Next.js 14.

If your images already sit on an image CDN such as Cloudinary or Imgix, let it do the resizing: set loader: 'custom' and a loaderFile that returns the CDN's URL for each width and quality. The Next.js docs include example loaders for many providers. The default loader does not forward request headers, so the docs suggest unoptimized for images that need authentication.

Which formats and quality settings should you use?

WebP is the default and still what Next.js recommends for most sites. It serves the first format in images.formats that the browser's Accept header supports. With ['image/avif', 'image/webp'], the docs put AVIF at about 20% smaller than WebP but about 50% slower to encode, so first requests are slower and each format is cached separately. A proxy or CDN in front of a self-hosted app must forward the Accept header.

Quality defaults to 75. Since Next.js 16, images.qualities is an allow-list that defaults to [75], and other quality values are served at the closest allowed one, so quality={90} gives you 75 until 90 is on the list.

Finally, check for images.unoptimized: true, which serves every file exactly as uploaded. Keep unoptimized for individual SVGs, images under 1KB and animated GIFs, which the docs say do not benefit from optimisation.

Where to start

  1. Give the LCP image on each main template loading="eager" and fetchPriority="high", or preload on its own.
  2. Add sizes to every image that uses fill or stretches with CSS.
  3. Check that remote images have real dimensions, or a sized parent with fill.
  4. Tighten remotePatterns, remove domains and list the qualities you use.

Then retest in PageSpeed Insights. Our web app development service builds and fixes Next.js apps this way, and a website review shows which apply to your site.

FAQ

Frequently asked questions

Why do our external images return a 400 error in Next.js?

Usually the URL does not match images.remotePatterns: protocol, hostname, port, path and query string all have to fit a pattern. Since Next.js 16, local images with a query string also need a matching images.localPatterns search entry, and a direct /_next/image request with a quality missing from images.qualities returns 400 too.

Does a blur placeholder stop layout shift?

No. A placeholder makes loading feel faster, but the space still comes from width and height, a static import, or a sized parent with fill. Next.js adds the blur data automatically for static imports of JPG, PNG, WebP and AVIF files that are not animated. For remote images you supply a very small data URL yourself, because a large one hurts performance.

How long does Next.js cache optimised images?

At least as long as images.minimumCacheTTL, which defaults to four hours since Next.js 16, or longer if the original image's Cache-Control header says so. There is no built-in way to clear that cache, so change the src when you replace an image. Statically imported images are hashed by content and served with a long-lived immutable cache header.

Can we use next/image with a static export?

Yes, but not with the default loader: its image optimisation needs a server, so it is unsupported with output: 'export'. Define a custom loader that points at an image service such as Cloudinary, and Next.js builds the srcset from that service's URLs. The other route is unoptimized, in which case you resize and compress the files yourself before upload.

Can we show a different hero image on mobile and desktop?

Yes, through art direction: call getImageProps() for each version and use the results in a <picture> element with a media condition per source. getImageProps() returns the same props <Image> would render, lazy loading included, so pass loading: 'eager' and fetchPriority: 'high' for a hero.

Next step

Ready for a website that sells?

Book a short call. We will look at your current site, agree what matters most and send a written scope with a fixed quote.

Book a callOr write to hello@sellwrightstudio.com