@d11/react-native-fast-image

中文文档
8.13.0发布于 2025/11/05(MIT AND Apache-2.0)TypeScriptESM + CJS零依赖近 30 天下载 66.4万

🚩 FastImage, performant React Native image component.

原始使用文档
文档目录16 节
  1. 🚀 What’s New?
  2. 🔥 Why Choose FastImage?
  3. ⚙️ Features
  4. 📦 Installation
  5. Optional: Disable SVG decoders
  6. Usage Example
  7. 🌐 Already Using Glide with an AppGlideModule ?
  8. 🛡️ ProGuard Config
  9. 📖 API Documentation
  10. Properties
  11. Static Methods
  12. 👥 Contributing
  13. 🛠️ Troubleshooting
  14. 🧪 Supported React Native Versions
  15. 👏 Credits
  16. ⚖️ License
⚠️ This is a fork of react-native-fast-image. All credit goes to the original author.

FastImage

A high-performance image component for React Native, now fully optimized for the New React Native Architecture! 🎉

🚀 What’s New?

FastImage now includes:

  • TurboModules and Fabric Renderer compatibility for enhanced performance.
  • AVIF Image Support for next-gen image formats.
  • Numerous bug fixes and performance improvements over the original repository.

🔥 Why Choose FastImage?

FastImage is a drop-in replacement for React Native’s Image component, offering solutions for common image loading challenges like:

  • Flickering during loading
  • Cache inconsistencies
  • Slow loading from cache
  • Overall suboptimal performance

FastImage leverages SDWebImage (iOS) and Glide (Android) for native caching and high efficiency.


Version Downloads Build Status Code Coverage

Watch on GitHub Star on GitHub Tweet


Experience blazing-fast images with the latest React Native technology.

⚙️ Features

  • ✅ Aggressive caching for high speed.
  • ✅ Customizable authorization headers.
  • ✅ Priority-based image loading.
  • ✅ Preloading for instant display.
  • ✅ Full GIF, SVG and AVIF support.
  • ✅ Support for borderRadius.
  • ✅ Support for Fabric Renderer (v8.7.0+).
  • ✅ Support for TurboModules (v8.8.0+).

📦 Installation

To install FastImage in your project, run:

Using yarn:

yarn add @d11/react-native-fast-image
cd ios && pod install

Or using npm:

npm install @d11/react-native-fast-image
cd ios && pod install

Note: You must be using React Native 0.60.0 or higher to use the most recent version of @d11/react-native-fast-image.

Optional: Disable SVG decoders

If you don't need SVG support, you can disable SVG decoders via an environment variable to reduce native dependencies/binary size:

  • iOS (before running CocoaPods):
export DISABLE_SVG=1 
cd ios && pod install
  • Android (before building):
export DISABLE_SVG=1
# then build as usual, e.g.
yarn android

To re-enable SVG support, unset the variable or set it to 0 and reinstall pods/rebuild.

Usage Example

import FastImage from "@d11/react-native-fast-image";
import * as React from "react";

const YourImage = () => (
  <FastImage
    style={{ width: 200, height: 200 }}
    source={{
      uri: "https://unsplash.it/400/400?image=1",
      headers: { Authorization: "someAuthToken" },
      priority: FastImage.priority.normal,
    }}
    resizeMode={FastImage.resizeMode.contain}
  />
);

🌐 Already Using Glide with an AppGlideModule?

If you're already using Glide and an AppGlideModule, read this guide to ensure smooth integration.

🛡️ ProGuard Config

If using ProGuard, add these rules to android/app/proguard-rules.pro:

-keep public class com.dylanvann.fastimage.* {*;}
-keep public class com.dylanvann.fastimage.** {*;}
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

📖 API Documentation

Properties

PropertyTypeDescription
sourceobjectSource for the remote image. Accepts an object with sub-properties like uri, headers, priority, and cache.
source.uristringThe URL to load the image from. e.g., "https://unsplash.it/400/400?image=1".
source.headersobjectHeaders to load the image with, e.g., { Authorization: "someAuthToken" }.
source.priorityFastImage.priorityLoad priority:
- FastImage.priority.low
- FastImage.priority.normal (Default)
- FastImage.priority.high
source.cacheFastImage.cacheControlCache control:
- FastImage.cacheControl.immutable (Default)
- FastImage.cacheControl.web
- FastImage.cacheControl.cacheOnly
defaultSourcenumberAn asset loaded with require() or import. Note: on Android, defaultSource does not work in debug mode.
resizeModeFastImage.resizeModeResize mode:
- FastImage.resizeMode.contain
- FastImage.resizeMode.cover (Default)
- FastImage.resizeMode.stretch
- FastImage.resizeMode.center
transitionFastImage.transitiontransition applied when displaying the image:
- FastImage.transition.none (Default)
- FastImage.transition.fade (React Native Image equivalent)
onLoadStartfunctionCallback when the image starts to load.
onProgress(event: OnProgressEvent) => voidCallback when the image is loading, with event.nativeEvent.loaded and event.nativeEvent.total bytes.
onLoad(event: OnLoadEvent) => voidCallback when the image is successfully loaded, with event.nativeEvent.width and event.nativeEvent.height values.
onError(event: OnErrorEvent) => voidCallback when an error occurs in loading the image or the source is malformed, with event.nativeEvent.error.
onLoadEndfunctionCallback when the image finishes loading, regardless of success or failure.
styleViewStyleStyle for the image component, supports borderRadius.
fallbackbooleanIf true, it will fall back to using Image. This still applies styles and layout as with FastImage.
tintColornumber or stringColor tint for all non-transparent pixels in the image.
testIDstringOptional ID for testing, such as with react-test-renderer.
blurRadiusnumberParameter for adjusting the blur in the image.

Static Methods

MethodDescription
FastImage.preload(sources: object[])Preloads images for faster display when they are rendered.
Example: FastImage.preload([{ uri: "https://unsplash.it/400/400?image=1" }]).
FastImage.clearMemoryCache(): Promise<void>Clears all images from the memory cache.
FastImage.clearDiskCache(): Promise<void>Clears all images from the disk cache.

👥 Contributing

We welcome contributions to improve FastImage! Please check out our contributing guide for guidelines on how to proceed.

🛠️ Troubleshooting

If you run into issues while using this library, try the solutions in our troubleshooting guide.

🧪 Supported React Native Versions

This project aims to support the latest version of React Native, simplifying development and testing. For older versions, consider forking the repository if you require specific features or bug fixes.

👏 Credits

The original idea for this module came from @vovkasm’s react-native-web-image package.

Special thanks to:

  • @mobinni for help with conceptualization.
  • SDWebImage (iOS) and Glide (Android) for powerful image caching.

⚖️ License

  • FastImage – MIT © DreamSportsLabs
  • SDWebImage – MIT
  • Glide – BSD, part MIT, Apache 2.0. See LICENSE for details.

版本与发布记录

@d11/react-native-fast-image 共发布 148 个版本,首次发布于 2024/05/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
8.13.0latest2025/11/051 年前
8.12.0-nightly-2025.9.25-14.25nightly2025/09/251.1 年前
8.12.0-nightly-2025.9.12-08.292025/09/121.2 年前
8.12.02025/09/051.2 年前
8.11.1-nightly-2025.9.05-06.572025/09/051.2 年前
8.11.1-nightly-2025.8.25-13.232025/08/251.2 年前

其他发布通道:next → 8.6.9-beta.0,nightly → 8.12.0-nightly-2025.9.25-14.25。

关于 @d11/react-native-fast-image 的常见问题

@d11/react-native-fast-image 是什么?

🚩 FastImage, performant React Native image component.

如何安装 @d11/react-native-fast-image?

在项目目录运行 npm install @d11/react-native-fast-image,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@d11/react-native-fast-image 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@d11/react-native-fast-image 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@d11/react-native-fast-image 可以商用吗?

@d11/react-native-fast-image 使用 (MIT AND Apache-2.0) 许可。声明的许可为 (MIT AND Apache-2.0),请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@d11/react-native-fast-image 的下载量有多少?

根据 npm 官方下载统计,@d11/react-native-fast-image 在 2026/10/11 – 2026/11/09 这 30 天内被下载 664,215 次,日均约 22,141 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@d11/react-native-fast-image 还在维护吗?

最新版本 8.13.0 发布于 2025/11/05(1 年前);至今共发布 148 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/05/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。