Bolt ui

Next.js Image Component Optimization Error

Using next/image causes errors. Image won't load or throws configuration error. Image optimization fails.

Error about missing width/height, or optimization service unavailable.

Error Messages You Might See

Error: Image with src should have width and height Error: Image Optimization API error Image domain not configured Unoptimized image with static size
Error: Image with src should have width and heightError: Image Optimization API errorImage domain not configuredUnoptimized image with static size

Common Causes

  1. Width/height not provided on Image component (required for static imports)
  2. External image domain not whitelisted in next.config.js
  3. Image format not supported by Next.js optimization
  4. Invalid src prop (relative path instead of absolute)
  5. Image optimization disabled but image props incorrect

How to Fix It

Always provide width and height: ...

For external images, add to next.config.js: { images: { remotePatterns: [{ hostname: 'example.com' }] } }

Use static import when possible: import img from '@/public/img.jpg'; ...

Ensure image file exists and is valid format (jpg, png, webp, gif)

Real developers can help you.

Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. Victor Denisov Victor Denisov Developer rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

When can I skip width/height?

Only with layout=fill (position: absolute parent) or static import with Babel plugin

How do I whitelist external image domains?

In next.config.js: images: { remotePatterns: [{ hostname: 'cdn.example.com', protocol: 'https' }] }

Is Image component always better than img tag?

Yes for web. Image automatically optimizes, lazy loads, handles responsive sizes. Always use next/image

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help