GitHub|Since 2007
Step 13

Image Optimization (next/image)

Boost your Web Vitals scores and performance by using the powerful Next.js Image component.

15 min

Supercharging Performance with Next.js Image

The standard `<img>` tag is a performance killer. Next.js provides the `<Image>` component to handle the heavy lifting of image optimization automatically.

1. Whitelisting the Domain

For security, you must tell Next.js which external domains are allowed to serve images. Update `next.config.js`:

images: {
  remotePatterns: [
    {
      protocol: 'https',
      hostname: 'yourwordpresssite.com',
    },
  ],
}

2. Key Features

  • Lazy Loading: Images are only loaded as they approach the viewport.
  • Format Selection: Automatically serves modern formats like WebP or AVIF if the browser supports them.
  • Responsive Resizing: Serves smaller images to mobile devices and high-res images to desktops.

3. Usage Tip

Use the `fill` property combined with a `relative` container and `object-cover` for hero sections and card thumbnails to ensure images always fit their containers perfectly without distortion.

Comments and Discussion