Image SEO and optimization rules for Next.js. Use when adding images, product photos, icons, banners, or working with the next/image component. Covers alt text, sizing, formats, lazy loading, and LCP optimization.
Technical rules for image implementation in a Next.js e-commerce site.
<img> tags — always use <Image> from next/image// GOOD
import Image from 'next/image';
<Image src={product.imageUrl} alt="Blue Widget Pro 3000 - front view" width={800} height={600} />
// BAD - never do this
<img src={product.imageUrl} alt="product image" />
The alt prop is required on every component. Search engines use alt text for image indexing and accessibility tools depend on it.
<Image>alt prop must always be present — never omit italt="" on purely decorative images (background patterns, visual separators)altText field when available, fall back to product name + context| Image Type | Alt Pattern | Example |
|---|---|---|
| Product main | {Name} - {Key Spec or View} | "Blue Widget Pro 3000 - front view" |
| Product gallery | {Name} - {Angle/Detail} | "Blue Widget Pro 3000 - control panel detail" |
| Category hero | {Description of content} | "Range of wireless headphones from 20Hz to 40kHz" |
| Icon/decorative | "" (empty) | alt="" |
| Logo | {Company} logo | "Acme Corp logo" |
// GOOD — descriptive, from data
alt={`${product.name} - ${image.viewLabel}`}
// BAD
alt="product image"
alt="image_0"
alt="" // on a meaningful product image
alt={product.sku} // Not human-readable
width and height — or use fill with a sized container// GOOD - explicit dimensions
<Image src={url} alt={alt} width={800} height={600} />
// GOOD - fill mode with container
<div className="relative aspect-[4/3] w-full">
<Image src={url} alt={alt} fill className="object-cover" />
</div>
// BAD - no dimensions, causes CLS
<Image src={url} alt={alt} />
priority on the LCP image — the largest above-the-fold image (usually the hero product photo)priority — it disables lazy loading and triggers preload// Product page hero image — this is the LCP element
<Image src={product.mainImage} alt={alt} width={800} height={600} priority />
// Gallery thumbnails — NOT priority, they're below fold or secondary
<Image src={product.thumbnail} alt={thumbAlt} width={200} height={150} />
Configure next.config.js for optimal format delivery:
// next.config.js
module.exports = {
images: {
formats: ['image/avif', 'image/webp'],
// If using an external image CDN:
remotePatterns: [
{ protocol: 'https', hostname: '*.your-cdn.com' },
],
},
};
remotePatternsloading="lazy" manually (it's redundant)priority for above-the-fold imagesUse blur placeholders for product images to reduce perceived loading time and CLS:
<Image
src={product.imageUrl}
alt={`${product.name} - ${image.viewLabel}`}
width={800}
height={600}
placeholder="blur"
blurDataURL={product.blurDataUrl} // Base64 tiny image
/>
Generate blurDataURL at build time or from the CMS/PIM system.
<img> tags — always use next/imagealt prop — every <Image> must have alt; use empty string only for decorative imagesalt="" for purely decorative imagessizes propremotePatterns config