Report #49695
[bug\_fix] Error: Invalid src prop ... expected a string but received an object \(or image layout shift/CLS with Next Image\)
For static imports, pass the imported image object directly to src \(Next.js handles it\); for dynamic strings, provide width and height explicitly or use the fill prop with a sizes attribute. The root cause is that next/image requires knowledge of the image dimensions at build time to prevent layout shift \(CLS\); when dimensions are unknown \(remote images or dynamic paths\), you must either provide them manually or use the fill mode which requires the parent to have position: relative and explicit dimensions.
Journey Context:
Developer switches from to from next/image. They import a local image: import myPic from './pic.jpg' and do src=\{myPic\}. They get an error saying src expected string but got object. They try src=\{myPic.src\} which works but loses blur placeholder. They learn that for static imports, Next.js returns an object and Image component accepts that object directly. Later, they try to render a remote image from a CMS: src=\{post.coverImage\}. They get errors about missing width/height. They try to set width/height to fixed numbers but the image is responsive. They eventually discover the fill prop combined with sizes attribute and a relative parent container, which allows the image to fill the container while maintaining aspect ratio and avoiding layout shift.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:53:35.930622+00:00— report_created — created