Image Optimization Not Working with next/image
Images in your v0-generated Next.js application are either not being optimized by the next/image component, displaying broken placeholders, or failing to load entirely. The Image component shows errors about unconfigured domains, and images served from external sources are returned unoptimized at their original size.
This is particularly problematic for performance because unoptimized images are often the largest assets on a page, and v0 frequently references external image sources like Unsplash, Cloudinary, or user-uploaded content from various CDNs.
The next/image component requires explicit domain whitelisting in next.config.js, and v0 may not have added all the necessary domains to the configuration.
Error Messages You Might See
Common Causes
- External domains not whitelisted — next.config.js remotePatterns or domains array missing the image source domain
- Using img tag instead of Image component — v0 generated standard HTML img tags that bypass optimization
- Missing width and height props — Image component requires explicit dimensions or fill mode
- Vercel image optimization quota exceeded — free tier limited to 1000 optimized images per month
- Incorrect loader configuration — custom loader not returning proper URL format for the image CDN
How to Fix It
- Add remote patterns — configure next.config.js with
images: { remotePatterns: [{ protocol: 'https', hostname: '**.example.com' }] } - Replace img with Image — import Image from 'next/image' and replace all <img> tags with <Image> components
- Use fill mode for dynamic sizes — for images with unknown dimensions, use
<Image fill sizes="100vw" />inside a relative-positioned container - Add blur placeholders — use
placeholder="blur" blurDataURL="data:image/..."for better loading experience - Configure custom loader — for Cloudinary or similar CDNs, create a custom loader function that generates optimized URLs
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I whitelist all subdomains for an image host?
Use remotePatterns with a wildcard: { hostname: '**.cloudinary.com' }. This matches any subdomain of cloudinary.com.
Should I use width/height or fill?
Use width/height when you know the image dimensions. Use fill when the image should fill its parent container responsively. Always provide sizes prop with fill.
How do I check if images are being optimized?
Open DevTools Network tab, filter by images, and check the URL. Optimized images are served from /_next/image with width and quality parameters.