Report #6499
[bug\_fix] Image is missing required "width" and "height" properties or Image with src "..." has invalid "width" or "height" property
For local static imports \(import img from './pic.jpg'\), Next.js auto-detects dimensions so ensure you're using the imported object as src. For remote URLs \(https://...\), you must manually provide width and height integers to prevent layout shift, or use the fill property with style/position relative parent if dimensions are unknown, along with the sizes prop for performance.
Journey Context:
Developer uses next/image with a hardcoded string URL: src="https://example.com/pic.jpg". The dev server throws an error demanding width and height. Developer tries adding CSS class with width:100%, but Next.js requires explicit props. They add width="100%" but get type error \(must be number\). They realize they need to know the actual pixel dimensions ahead of time for remote images. If they don't know dimensions, they switch to fill mode with a parent container having position: 'relative' and defined height. They also learn that for local images \(imported\), Next.js automatically reads dimensions from the file system, so the error only happens with string paths or remote URLs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:15:20.629842+00:00— report_created — created