Next.js Discord

Discord Forum

WebP & avif Images - don't work

Unanswered
Sutherman posted this in #help-forum
Open in Discord
I have this in my next.config.js:
/**
 * @type {import('next').NextConfig}
 */

const nextConfig = {
  reactStrictMode: true,
  distDir: ".next",
  output: 'standalone',
  images: {
    formats: ['image/webp','image/avif'], // Reihenfolge = Präferenz
  },
};

module.exports = nextConfig;

This should generate WebP and AVIF Images for Browser which support those File-Formats.
But I found that this doesn't work at all.

I've made sure, that the Image is insert via <Image>-Tag:
hdiv className="relative">
                    <Image
                      className="mx-auto mb-14"
                      src={banner.image}
                      width={750}
                      height={390}
                      priority
                      fetchPriority="high"
                      sizes="(max-width: 640px) 100vw,
                             (max-width: 1024px) 80vw,
                             50vw"
                      style={{
                        maxWidth: "90%",
                        height: "auto",
                        border: "2px solid #fff",
                        borderRadius: "16px",
                        boxShadow: "0 12px 40px rgba(0,0,0,0.15)"
                      }}/>

                  </div>

But after Deploy, the image is still delivered as jpeg (see image 1)
Any Idea why?

5 Replies

Macao paper wasp
Did you make sure your browser is advertising it supports this image format? By checking the image request headers, you should see something like: Accept: image/avif,image/webp...
You're using <Image /> and formats: ['image/webp', 'image/avif'] correctly ✅
If images still show as .jpg, it’s likely one of these:

### 🔍 Checklist:

1. Are you testing with next build && next start? (next dev skips optimization)
2. Browser must support and request webp/avif
3. Image must be local (/public/...) or from a trusted domain

---

### ✅ Example (local image):

import Image from "next/image"

export default function Hero() {
  return (
    <Image
      src="/images/suther.jpg"
      width={750}
      height={390}
      alt="Samuel Suther"
      priority
      className="mx-auto mb-14"
      style={{
        maxWidth: "90%",
        height: "auto",
        border: "2px solid #fff",
        borderRadius: "16px",
        boxShadow: "0 12px 40px rgba(0,0,0,0.15)"
      }}
    />
  )
}


Then run:

next build && next start


➡️ Open devtools → Network → check image Accept header
➡️ Should show .webp or .avif if the browser supports it

Let me know if you're hosting images externally or need to allow domains.
@Sutherman
@Rash