Questions tagged [nextjs-image]

next/image is the built-in image component in NextJS 10. Please, do not use this tag for questions related to the next-images package (use [next-images] instead).

next/image is the Next.js team's solution to performant images on the web. The Next.js Image Component is just a drop-in replacement for the HTML <img> element, evolved for the modern web.

When using the next/image component, images are automatically lazy-loaded, meaning they're only rendered when the user is close to seeing the image. This prevents loading that 30% of images outside of the initial viewport.

The Automatic Image Optimization allows for resizing, optimizing, and serving images in modern formats like WebP when the browser supports it. This avoids shipping large images to devices with a smaller viewport. It also allows Next.js to automatically adopt future image formats and serve them to browsers that support those formats.

Automatic Image Optimization works with any image source. Even if the image is hosted by an external data source, like a CMS, it can still be optimized.

For usage and available props visit https://nextjs.org/docs/api-reference/next/image

310 questions
8
votes
1 answer

Is there a way to index the images generated by "Next/Image Component" in Google Image Search?

I am having issues with indexing the images that are optimized by the Next/Image component these images are in the public folder of my Next.js app. I haven't seen any examples where any resource/URL like below, that was generated by Next/Image…
Adam Hill
  • 315
  • 3
  • 8
8
votes
0 answers

Using next/image in npm package

I am running a Next.js app and a Storybook component library. I would like to use next/image in Storybook so that I can take advantage of the image optimization. I followed this article to mock next/image in Storbook. This library is bundled using…
a-windett
  • 151
  • 1
  • 7
8
votes
2 answers

Why should I use 'next/image'?

I am new to NextJS but I have a very good experience in ReactJS and Webpack. My question is NextJS offers a package 'next/image'. I want to know or understand very deeply that why I should use their package to load an image no the default img…
moshfiqrony
  • 4,303
  • 2
  • 20
  • 29
7
votes
2 answers

How to get width and height attributes on img element using Next/Image

The image is working just fine. Here is the code Example image But, when I run the website on web.dev, I don't get a topscore in Performance. The main…
jonask
  • 679
  • 2
  • 6
  • 21
7
votes
3 answers

Next.js Image component error src missing though I am providing the src prop

I am providing the src prop to the UserCard but then also I am getting the error below. Error Unhandled Runtime Error Error: Image is missing required "src" property. Make sure you pass "src" in props to the `next/image` component. Received:…
KUSHAD
  • 127
  • 1
  • 2
  • 8
6
votes
3 answers

Nextjs Image an issue with "loader" property that does not implement width

This is my code for the Nextjs Image component: ... Cell: ({ value }: CellType) => ( value} className={''} height={100} width={100} alt={'profile_picture'} /> ), Does it…
Natalia Bizitza
  • 103
  • 2
  • 9
6
votes
1 answer

How can I use next-image to scale images down to "max-width" and "max-height"?

I have a blog that uses images with different scales and aspect ratios. Some are short and wide, some are tall and narrow. You can see an example here. I want my images to: Be at most as wide as the post (no larger than 100% width of their…
lumenwrites
  • 1,287
  • 4
  • 18
  • 35
6
votes
1 answer

Next.js searches images in local directory not on AWS

We are converting our app to Next.js from Create React App. Next.js should load images from AWS but this not happen. Why? It worked some days ago. Do you think it's some caching problems or what? Do you any ideas? In Next.js the app loads the images…
6
votes
3 answers

Next Image component throws 404 error in production, works fine in development

I have a bunch of images in a hidden gallery, only shown when a user clicks on a certain button. On the development server, everything is fine, no errors or issues, but when I deploy my website and open the gallery the images don't show and throw a…
5
votes
3 answers

NextJS/Image: "url" parameter is valid but upstream response is invalid

I am trying to fetch images from Strapi into my NextJS Application, but whatever I am trying to do I am always getting the error "url" parameter is valid but upstream response is invalid" The console is stating: Failed to load resource: the…
Ibo
  • 159
  • 1
  • 7
5
votes
0 answers

Is there a way to set prefix for all local images in next js using next.config.js?

I have setup my next js code with some static images into the system which is used as Alt but now I have to deploy it with basePath: '/product. Urls are…
Lokesh
  • 152
  • 1
  • 8
5
votes
0 answers

PNG and JPEG images not working in Next.js with next-optimized-images

I use next-optimized-images with next.js v11.0.1 and also installed imagemin-mozjpeg imagemin-optipng imagemin-svgo. SVG images work fine but when I try for .png or .jpg images, no image will show instead alt attribute text or broken image is…
5
votes
1 answer

How to get image width/height in next.js?

In my app I allow users to upload their images. Upon uploading it goes into public folder, and in database there is only a direct link for future requests. When displaying these images on the page I encounter a problem. Image component wants to know…
Arctomachine
  • 401
  • 6
  • 12
5
votes
0 answers

Why does next/image generate inline styling that resets my css?

I’m intending to use next/image to optimize the images on my site. However, after building the project, all of my images are getting a style attribute with what seems to be reset styling. I’m new to React and Next.js and I can't seem to find anyone…
5
votes
2 answers

Using Nextjs Image component with different image sizes

I am trying to use the Next.js Image component with images that all have unique sizes. Their example states the image will stretch to the parent div width and height. I've tried wrapping them but don't know how to accommodate dynamic image sizes. I…
sn4ke
  • 587
  • 1
  • 14
  • 30
1 2
3
20 21