In-depth Next.js guides covering App Router, RSC, ISR, and deployment. Get code examples, optimization checklists, and prompts to accelerate development.
If you're dealing with images in Next.js 15, it's easy to shoot yourself in the foot by misunderstanding how images are handled under the hood. Here's the distinction that matters: are you importing the image or referencing it via URL?
I've seen people (myself included) load local images via dynamic URLs thinking Next.js will optimize them. Spoiler: it won't. And that leads to bad performance, no blur effect, no srcset, no compression. The whole point of next/image is lost.
Two ways to use images in Next.js
Let's break it down with real examples.
1. Static import (recommended for local images)
First, make sure your tsconfig.json has the right path mapping for easier imports:
// ❌ Wrong - treating local image like remoteimportImagefrom'next/image'exportdefaultfunctionBadExample() {
return (
<Imagesrc="/gallery/photo.jpg" // LocalfilereferencedbyURLalt="Photo"width={800}height={600}
// Thiswon'tgetoptimized!
/>
)
}
This looks fine, but if that image is just sitting in /public and was never imported, you're serving a raw image directly.
What you lose:
No automatic blur placeholder
No build-time compression
No responsive srcSet generation
No format optimization
Larger bundle size and slower loading
Your Lighthouse score drops. Mobile users suffer.
When you need blur effects with local URLs
Sometimes you need to reference local images by URL (maybe for dynamic galleries or CMS-like scenarios). In these cases, you can still get blur effects by generating blurDataURL yourself:
Custom preprocessing before shipping files elsewhere
Creating specific sizes for art direction
But for general use with next/image, you don't need it. Next.js handles optimization better than manual preprocessing.
Quick checklist
✅ Do this:
Import local images: import img from '@/public/img.jpg'
Configure remote patterns for external images
Use priority for above-the-fold images
Let Next.js handle optimization automatically
❌ Don't do this:
Reference local images by URL path
Manually compress images that Next.js could optimize
Skip the alt attribute
Forget to configure remotePatterns for external images
The next/image component is powerful when used correctly. Import local images, configure remote sources properly, and let Next.js handle the heavy lifting. Your users (and Lighthouse scores) will thank you.