Speed Matters: Optimize Image Performance in Next.js 15 Like a Pro

Adhithi Ravichandran
2 min readApr 10, 2025

--

Modern web apps aren’t just about clean code or flashy UIs; they’re about performance. And one of the biggest culprits slowing down your site?

Images.

In this post, you’ll learn how to optimize images in Next.js 15 using built-in tools like next/image and real-world strategies that can drastically improve load times, especially on mobile.

Why Optimize Images?

Over 50% of a web page’s total size can come from images.

Images make up approximately 50% of a webpage’s weight

Poorly optimized assets can:

  • Slow down your time to first paint
  • Tank your Lighthouse and Core Web Vitals
  • Push users to bounce

The next/image Component: Built-in Performance

Next.js gives you a battle-tested tool to solve these issues: the next/image component.

import Image from 'next/image';

export default function Hero() {
return (
<div className="relative w-full h-[400px]">
<Image
src="/images/pie-banner.jpg"
alt="Bethany's delicious pies"
fill
priority
className="object-cover"
/>
</div>
);
}
  • fill: Automatically sizes to the parent container
  • priority: Loads the image ASAP (great for hero images)
  • object-cover: Preserves aspect ratio while filling space

Serve Optimized Sizes

Next.js serves the optimal image size for the user’s device. You can also fine-tune behavior via next.config.js:

// next.config.js
module.exports = {
images: {
deviceSizes: [640, 768, 1024, 1280, 1600],
domains: ['cdn.example.com'],
},
};

Mobile-First Wins

Make sure you’re giving mobile users the best experience:

<Image
src="/images/pie.jpg"
alt="Freshly baked pie"
width={800}
height={600}
sizes="(max-width: 768px) 100vw, 50vw"
className="rounded-xl shadow"
/>

This makes use of the sizes prop, which helps the browser decide how large the image will render on different devices, leading to more efficient downloads.

Deploy Smartly with Vercel

If you’re deploying your app on Vercel, image optimization works out of the box. No configuration needed. For custom deployments, you can set up your own image loader.

Want More Real-World Strategies?

Are you looking to optimize your Next.js app and scale it? In my Pluralsight course, we explore:

It’s perfect for frontend developers looking to ship faster, lighter, and more scalable React apps with Next.js 15.

--

--

Adhithi Ravichandran
Adhithi Ravichandran

Written by Adhithi Ravichandran

Software Consultant, Author, Speaker, React|Next.js|React Native |GraphQL|Cypress|Playwright Dev & Indian Classical Musician

No responses yet