vercel/next.js · error · Error
Image with src "${src}" has invalid "width" property. Expect
Error message
Image with src "${src}" has invalid "width" property. Expected a numeric value in pixels but received "${width}". What it means
Props validation in getImgProps: width was present but parsed to NaN (e.g. a string like "auto" instead of a pixel number). The prop expects a numeric pixel value for non-fill images; the received raw value is echoed in the message.
Source
Thrown at packages/next/src/shared/lib/get-img-props.ts:513
)
}
if (style?.width && style.width !== '100%') {
throw new Error(
`Image with src "${src}" has both "fill" and "style.width" properties. Images with "fill" always use width 100% - it cannot be modified.`
)
}
if (style?.height && style.height !== '100%') {
throw new Error(
`Image with src "${src}" has both "fill" and "style.height" properties. Images with "fill" always use height 100% - it cannot be modified.`
)
}
} else {
if (typeof widthInt === 'undefined') {
throw new Error(
`Image with src "${src}" is missing required "width" property.`
)
} else if (isNaN(widthInt)) {
throw new Error(
`Image with src "${src}" has invalid "width" property. Expected a numeric value in pixels but received "${width}".`
)
}
if (typeof heightInt === 'undefined') {
throw new Error(
`Image with src "${src}" is missing required "height" property.`
)
} else if (isNaN(heightInt)) {
throw new Error(
`Image with src "${src}" has invalid "height" property. Expected a numeric value in pixels but received "${height}".`
)
}
// eslint-disable-next-line no-control-regex
if (/^[\x00-\x20]/.test(src)) {
throw new Error(
`Image with src "${src}" cannot start with a space or control character. Use src.trimStart() to remove it or encodeURIComponent(src) to keep it.`
)
}View on GitHub (pinned to 0eb3775416)
Solutions
- Pass width as a number of pixels (not a string like "100%").
Defensive patterns
Strategy: validation
When it happens
Trigger: next/image width prop is not a numeric pixel value.
Common situations: Passing a string like '100px' or '50%' as width to next/image.
AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19).
Data as JSON: /api/errors/be3e021ebee51da7.
Report an issue: GitHub.