react-native-fast-image
🚩 FastImage, performant React Native image component.
react-native-fast-image is a drop-in replacement for React Native's built-in Image component that fixes flickering, cache misses, and slow scrolling by using battle-tested native image libraries on iOS and Android.
react-native-fast-image is a drop-in replacement for the built-in Image component in React Native, the framework used to build iOS and Android apps with JavaScript. The standard Image component handles image loading adequately in many situations, but developers have frequently reported flickering when images reload, cache misses that cause already-seen images to download again, and sluggish performance when scrolling through lists of images. This library addresses those problems.
Under the hood, FastImage wraps two established native image-loading libraries: SDWebImage on iOS and Glide on Android. Both of those libraries have been battle-tested in native app development and bring their caching and memory management strategies into the React Native world.
The library provides several options beyond what the built-in component offers. You can assign a priority level to each image (low, normal, or high), which controls which downloads happen first when multiple images are loading at the same time. You can attach custom HTTP headers to image requests, including authorization tokens for protected image URLs. You can preload a list of images before they appear on screen, so they are already cached by the time the user scrolls to them. Cache behavior is configurable per image: you can tell the library to treat the URL as permanent and never re-download, to follow standard HTTP cache headers, or to only show images already stored on disk.
The component supports GIF images, border radius styling, and callbacks for load start, progress, completion, and error events. There is also a method to clear the in-memory or on-disk cache programmatically. The library is MIT-licensed and requires React Native version 0.60 or later. It targets the latest version of React Native and does not maintain compatibility with older releases.
Where it fits
- Replace the standard React Native Image component to eliminate flickering when images reload in lists or navigating back to a screen.
- Preload a batch of images before a screen opens so they appear instantly when the user scrolls to them.
- Load images from protected URLs by attaching an Authorization header to each image request without a proxy.
- Configure per-image cache policy, force re-download, follow HTTP cache headers, or only show images already on disk.