Image Optimization for Next.js: Complete Guide 2025
Why Next.js Image Optimization Matters
Next.js is the most popular React framework, and its built-in image component is one of its most powerful features. But many developers leave default settings untouched and miss out on significant performance gains. In this complete guide, you will learn how to get the most out of Next.js image optimization in 2025.
Images are usually the largest resources on a page. Google's Largest Contentful Paint (LCP) metric is almost always triggered by a hero image, and LCP directly affects your search ranking. Optimizing images in Next.js is therefore an SEO task, not just a performance nicety.
The next/image Component
The next/image component is the cornerstone of Next.js image optimization. It automatically handles:
srcsetwidth and height to prevent CLS``jsx
import Image from 'next/image'
The priority prop tells Next.js to preload the image - use it only for the LCP element (usually your hero image). The sizes attribute helps the browser pick the right resolution, preventing the download of unnecessarily large files.
Automatic Format Selection
When you use next/image with the default image optimizer, Next.js inspects the Accept header of each request and serves the best format:
| Browser Accepts | Format Served |
| image/avif | AVIF |
| image/webp | WebP |
| (fallback) | Original (JPEG/PNG) |
To enable AVIF (which is 20-30% smaller than WebP), add it to your config:
`js
// next.config.js
module.exports = {
images: {
formats: ['image/avif', 'image/webp'],
},
}
`
For a deeper look at how these formats compare, read our WebP vs AVIF guide.
When to Pre-Optimize Instead of Relying on the Optimizer
The built-in optimizer is excellent, but it has limitations:
) disable it entirely.The Pre-Optimization Workflow
For static sites, high-traffic apps, or when you want maximum control, pre-optimize your images before they reach Next.js:
directoryThen reference the pre-optimized files directly with next/image using the unoptimized prop, or serve them via a CDN. This eliminates runtime processing entirely.
Responsive Images with sizes
The single most common mistake is omitting the sizes attribute. Without it, Next.js assumes the image is full-width and downloads the largest variant. Always provide accurate sizes:
`jsx
`
This tells the browser: "On mobile, this image is full width. On tablet, half width. On desktop, a third of the viewport." The browser then downloads the smallest sufficient resolution.
Common Mistakes to Avoid
1. Forgetting width and height
Omitting dimensions causes layout shift (poor CLS). Always include the intrinsic aspect ratio - Next.js uses it to reserve space before the image loads.
2. Using priority on every image
priority triggers a preload hint. Use it for the single LCP image only. Adding it everywhere defeats the purpose and slows initial load.
3. Serving oversized source images
Even with optimization, a 6000×4000 source image wastes processing time. Resize first. Our bulk converter can resize and convert in one step - see our batch resize guide for the full workflow.
4. Ignoring the placeholder
Use placeholder="blur" with blurDataURL for a smooth loading experience. This prevents the jarring flash of an empty container.
Measuring the Impact
After implementing these techniques, expect to see:
| Metric | Before | After | Improvement |
| LCP | 3.5s | 1.6s | -54% |
| Page weight | 3.2MB | 850KB | -73% |
| CLS | 0.18 | 0.02 | -89% |
| Lighthouse score | 62 | 96 | +55% |
Start Optimizing
Pre-optimize your images with our free bulk converter - convert to WebP or AVIF, resize to exact dimensions, and download as a ZIP. No upload, no sign-up, fully private. For the broader context of reducing page weight, see our image size reduction guide.
Common Next.js Image Mistakes
tag doesn't get automatic optimizationPerformance Budgets
Set performance budgets for your Next.js project:
Related Guides
Ready to optimize your images?
Try BulkPicConv — Free