Image
Why use over <img>
?
Images are lazy loaded meaning not loaded if outside viewpoint/unless scrolled to
nextjs will automatically create optimized images in WebP for all device heights and widths, including a jpg fallback for older browsers
Require image ratio to prevent Cumulative Layout Shift,
Usage
Needs image ratio(width/height) to prevent Cumulative Layout Shift,
If imported, Next.js will automatically determine it
If remote, need to set intrisic width and height not style width and height thats different (or use fill if unknown)
Need to explicitly allow remote image hosts in
next.config.js
to safely optimizeCan use fill, but parent element must have
position: relative
anddisplay:block
next.config.js
Last updated