Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Extending Next.js' <Image /> component to improve UX
Next Image With State is a small open-source Next.js library that improves image-loading UX by extending the built-in Image component to show a skeleton loader while an image loads and a fallback image when the browser fails to load it.
Next Image With State is a drop-in extension of Next.js' Image component that adds two loading-state behaviors: a SkeletonLoader while an image is loading and a fallback image when loading errors. It runs on Next.js projects, takes the same props as Next's Image component plus two new props, and outputs the rendered image with loading and error states handled. The repository is listed with the topics next-image, nextjs-blog, nextjs-template, and ux, and currently has 2 stars.
ImageWithState exactly like Next's Image component; all existing Image props continue to work.fallback prop (string, required) takes the path of the image to display when the browser fails to load the original.debug prop (boolean, optional) makes it easy to see how the SkeletonLoader is positioned and styled, helpful while tuning layout.<Image /> for <ImageWithState /> and pass a fallback path to get skeleton loading and broken-image handling.debug prop to inspect and adjust the SkeletonLoader's positioning and styling before shipping.The package wraps Next.js' Image component so the same API is preserved and adds two props. When the image begins loading, the SkeletonLoader renders; if the browser fails to load the image, the fallback prop's path is shown instead. The debug prop toggles visual aids for the skeleton's position and style.
The repository is public on GitHub, and no pricing or licensing details are listed on the page.
It adds fallback (string, required) for the fallback image path and debug (boolean, optional) to visualize how the SkeletonLoader is positioned and styled.
When the browser fails to load the image, ImageWithState displays the image at the path given in the fallback prop instead of showing a broken-image placeholder.
You can use ImageWithState the same way you use Next's Image component, so existing Image props keep working and only the component name changes.
