Next.js Discord

Discord Forum

Sizes prop in <Image> component, ELI5

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I've always been using the <Image> component with the fill prop, but I've never used the sizes one: https://nextjs.org/docs/pages/api-reference/components/image#sizes I'm reading the docs and I don't understand what it does. I thought NextJS Images were automatically served with the proper size according to the device of the user, was I wrong? Is the sizes prop the thing that takes care of that? As an example, I have a hero image that always takes up the whole screen width, I've added the sizes prop like this:
<Image
      src="/example.png"
      fill
      sizes="100vw"
    />
and I don't see any difference when it comes to the srcset of images when i inspect element, so I can't figure out what it's actually doing

0 Replies