Report #44032
[bug\_fix] Next.js Image component missing width and height \(or fill\) causing build errors or layout shift.
For local images, import the image to get automatic width/height, or provide explicit width and height. For remote images of unknown size, use the \`fill\` prop and ensure the parent container has \`position: relative\`. The root cause is that Next.js Image requires explicit dimensions to prevent Cumulative Layout Shift \(CLS\); without them, the browser cannot reserve space during page load.
Journey Context:
Developer adds an image: \`import Image from 'next/image'; \`. They expect it to render like a standard img tag. Instead, \`next dev\` throws an error: 'Image with src "/hero.jpg" is missing required "width" and "height" properties'. Developer tries adding arbitrary numbers like width=\{800\} height=\{600\}, but the image is responsive and they don't know the aspect ratio. They try using \`layout="fill"\` \(deprecated in Next 13\) or the new \`fill\` prop. They add \`fill\` but the image vanishes or has zero height because the parent div has no explicit height or \`position: relative\`. After reading the Next.js docs, they realize that for local images, the best practice is to \`import hero from './hero.jpg'\` and pass it to src, which automatically provides width/height. For remote images \(external URLs\), they must provide width/height explicitly to prevent CLS, or use \`fill\` with a parent container styled with \`position: relative\` and explicit dimensions or aspect-ratio. This ensures the server-rendered HTML includes the size attributes, reserving space before the image loads.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T04:22:55.911882+00:00— report_created — created