Components

Image

Image helps you display the image in an optimal manner. By default, it waits up to 5 seconds (configurable) for an image resource to fully load before displaying it, mitigating display issues with certain formats like baseline JPEGs. If loading exceeds 5 seconds, the component will display the partially-loaded image anyway to indicate progress.

Props
widthnumberRequired
The instristic image width which is used to prevent layout shifts. This should not be considered the final image width.
heightnumberRequired
The instristic image height which is used to prevent layout shifts. This should not be considered the final image height.
placeholderstring
The image displayed until the actual image fully loads. It's recommended to use a base64 data URL for immediate rendering.
maxJSWaitTimenumber
The total time waiting for actual image to load. If this time is exceeded, the partially-loaded image will be displayed to inform users of the loading progress.
Plus all props from HTML <img>

Usage

  function Image() {
    return (
      <Image
        alt=""
        src="https://image-demo-1200px.jpg"
        width={1600}
        height={900}
        srcSet="
          https://image-demo-200px.jpg 200w,
          https://image-demo-600px.jpg 600w,
          https://image-demo-1200px.jpg 1200w,
        "
        sizes="(min-width:640px) 330px, 80vw"
        placeholder="data:image/webp;base64,UklGRuYAAABXRUJQVlA4INoAAADwBwCdASpkAEMA"
      />
    )
  }

Behaviors

There is no difference in behavior between the hydrated and unhydrated modes.

A timer is set when the HTML is parsed. By default, if the image fully loads within 5 seconds (configurable), it will be displayed all at once. This approach helps to prevent display issues associated with certain image formats, such as baseline JPEGs.

If the loading time exceeds 5 seconds, the partially-loaded image will be displayed regardless of how much data has been loaded. This ensures that users are not stuck viewing the placeholder, keeping them informed about the image's loading progress.