next/image is two things: a component that writes <img> markup, and an optimizer route, /_next/image?url=…&w=…&q=…, that produces the files the markup points at.
The component, on Next.js 16.4.5 (next build && next start):
- builds
srcsetfromdeviceSizesandimageSizes. A 400 px image withoutsizesgotw=640 1x, w=828 2x; withsizes, ninewcandidates from 384w to 3840w;fillwithoutsizesgotsizes="100vw"and device widths only. - adds
loading="lazy"anddecoding="async"by default.preload(and the deprecatedpriority) dropsloadingand puts<link rel="preload" as="image" imagesrcset>in<head>. Neither addsfetchpriority. - writes
widthandheightto reserve space; for a static import it reads them, and a blur placeholder, at build.
The optimizer, per request:
- checks
urlagainstlocalPatterns/remotePatterns,wagainst the configured widths andqagainstqualities(default[75]). Anything else is a400such as"q" parameter (quality) of 80 is not allowed. - resizes without upscaling (
w=3840of a 1600 px source came back 1600 px wide) and picks the format fromAcceptandimages.formats: WebP by default, AVIF only if configured, the original JPEG forAccept: */*. - caches the result in
.next/cache/imagesand sendsCache-Control: public, max-age=14400, must-revalidate(minimumCacheTTL, 4 hours since 16), ormax-age=315360000, immutablefor static imports, withX-Nextjs-Cache: MISS, thenHIT.
What stays yours: dimensions or fill inside a positioned, sized parent; a sizes that matches the layout; real alt text; the host allowlists; and preload or loading="eager" on the one image that is the LCP element. Why those matter (LCP, CLS) belongs to Web performance. next/image only nags about them in development.