typescriptintermediate
Next Image Responsive Patterns
Use next/image with responsive sizes, blur placeholders, and priority loading for optimal image delivery.
typescriptPress ⌘/Ctrl + Shift + C to copy
import Image from 'next/image';
// Responsive image with sizes
export function HeroImage() {
return (
<Image
src="/hero.jpg"
alt="Hero banner"
width={1920}
height={1080}
priority // Load immediately (above fold)
sizes="100vw"
className="w-full h-auto object-cover"
/>
);
}
// Fill container (like background-image)
export function CardImage({ src, alt }: { src: string; alt: string }) {
return (
<div className="relative aspect-video overflow-hidden rounded-lg">
<Image
src={src}
alt={alt}
fill
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
className="object-cover"
/>
</div>
);
}
// Blur placeholder
export function GalleryImage({ src, alt, blurDataURL }: {
src: string;
alt: string;
blurDataURL: string;
}) {
return (
<Image
src={src}
alt={alt}
width={400}
height={300}
placeholder="blur"
blurDataURL={blurDataURL}
className="rounded-lg transition-opacity"
/>
);
}
// Remote image (requires next.config.ts)
// images: {
// remotePatterns: [
// { protocol: 'https', hostname: 'images.unsplash.com' },
// ],
// }Use Cases
- responsive images
- hero banners
- image galleries
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
typescriptbeginner
Next.js Image Optimization Patterns
Advanced next/image usage with responsive sizes, blur placeholders, and custom loaders.
Best for: Optimizing Core Web Vitals with proper image loading
#nextjs#image
typescriptbeginner
Font Optimization with next/font
Use next/font for automatic self-hosted font optimization with zero layout shift.
Best for: custom typography
#nextjs#fonts
typescriptintermediate
Responsive Image Component
Image component with lazy loading, blur placeholder, error fallback, and srcset support.
Best for: Image galleries
#image#responsive
typescriptbeginner
Next.js Image Optimization Patterns
Use next/image with responsive sizes, blur placeholders, and priority loading for optimal Core Web Vitals.
Best for: Hero images
#images#optimization