Files
vercel__next.js/errors/invalid-images-config.mdx
Steven 600238f0b6 breaking(next/image)!: remove 16px from default images.imageSizes config (#84647)
We took a look at unique Next.js projects that have one or more requests
for a specific image size and here are the findings as seen from the
Image Optimization API:

- `w=16` 4.2%
- `w=32` 17.1%
- `w=48` 21.4%
- `w=64` 22.6%
- `w=96` 25.8%
- `w=128` 29.5%
- `w=256` 46.5%
- `w=384` 35.1%
- `w=640` 57.2%

Only 4.2% of Next.js projects ever made a request to a 16px width image.
This is low enough to remove from the default configuration so that all
other projects can benefit from reduced html
[srcset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset)
and fewer variations exposed from the backend API.

You might think that this means few developers are using `<Image
width={16} />` but it probably means that most displays nowadays use
devicePixelRatio 2 meaning that specifying a 16px image width will
actually fetch the 32px width to ensure it won't looking blurry on your
retina display.

BREAKING CHANGE: this is technically a breaking change but it won't
cause apps to stop working, its just 4% of them may have some requests
serve a 32px image instead of 16px. Those apps can of course opt in by
changing their `images.imageSizes` config back to allowing 16.
2025-10-09 14:31:58 +02:00

56 lines
1.8 KiB
Plaintext

---
title: 'Invalid `images` config'
---
## Why This Error Occurred
In your `next.config.js` file, you provided an invalid config for the `images` field.
## Possible Ways to Fix It
Make sure your `images` field follows the allowed config shape and values:
```js filename="next.config.js"
module.exports = {
images: {
// limit of 25 deviceSizes values
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
// limit of 25 imageSizes values
imageSizes: [32, 48, 64, 96, 128, 256, 384],
// limit of 50 domains values (deprecated)
domains: [],
// path prefix for Image Optimization API, useful with `loader`
path: '/_next/image',
// loader can be 'default', 'imgix', 'cloudinary', 'akamai', or 'custom'
loader: 'default',
// file with `export default function loader({src, width, quality})`
loaderFile: '',
// disable static imports for image files
disableStaticImages: false,
// minimumCacheTTL is in seconds, must be integer 0 or more
minimumCacheTTL: 14400, // 4 hours
// ordered list of acceptable optimized image formats (mime types)
formats: ['image/webp'],
// enable dangerous use of SVG images
dangerouslyAllowSVG: false,
// set the Content-Security-Policy header
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
// sets the Content-Disposition header ('inline' or 'attachment')
contentDispositionType: 'attachment',
// limit of 25 objects
localPatterns: [],
// limit of 50 objects
remotePatterns: [],
// limit of 20 integers
qualities: [25, 50, 75],
// when true, every image will be unoptimized
unoptimized: false,
},
}
```
## Useful Links
- [Image Optimization Documentation](/docs/pages/api-reference/components/image)
- [`next/image` Documentation](/docs/pages/api-reference/components/image)