Report #66048
[bug\_fix] Image is missing required 'width' property or 'fill' property with 'sizes'
For local images imported with next/image, Next.js auto-detects dimensions. For remote images \(strings\), provide explicit width/height integers, or use fill with sizes attribute ensuring the parent container has position: relative and defined dimensions. Root cause: Next.js Image component requires explicit sizing to prevent Cumulative Layout Shift \(CLS\) by reserving space before image loads.
Journey Context:
Developer replaces standard with Next.js expecting optimization. Immediately gets compile error demanding width/height. Tries adding style=\{\{width: '100%', height: 'auto'\}\}, but error persists because component requires explicit numeric props for intrinsic sizing. For a responsive hero image, tries width=\{800\} height=\{600\} but image stretches on mobile. Discovers fill mode: sets fill=\{true\} and sizes="100vw", but image collapses to 0x0 pixels. Inspects elements, realizes parent div has no defined height. Adds relative positioning and h-64 \(height\) to parent. Image appears correctly responsive. Dives into Core Web Vitals docs, understands Next.js enforces CLS prevention by requiring explicit space reservation, unlike standard img which allows layout shifts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:20:27.053855+00:00— report_created — created