Question presented to candidate: "Explain what the Next.js Image component does for you compared with a plain img tag, and how you would make a hero image load fast."
What a strong answer should cover:
- It resizes and converts images on demand through
/_next/image, choosing WebP or AVIF from the browser Accept header, and caches the results. - It generates
srcsetand usessizesso the browser downloads only the width it needs. - It lazy-loads by default and reserves space with width and height (or the imported file size), preventing layout shift.
- For the LCP image use
preload(Next.js 16 deprecatespriority),loading="eager"orfetchPriority="high". - Remote images must be allowed in
images.remotePatterns; qualities are limited toimages.qualities(only 75 by default in 16).
Clarifying questions expected:
- "Which image is the largest thing above the fold?" β that one gets preload.
- "How wide is the image on each screen size?" β that determines
sizes.
Code / implementation expected: Yes β a lazy responsive image and a preloaded hero.