Download Files

React Native 6 min min read Updated: Jul 26, 2026 Intermediate
Download Files
Intermediate Topic 14 of 20

Download Files

Downloading files, such as PDFs, images, or documents, is a common requirement for apps that let users save content locally on their device. This tutorial explains how to implement file downloads in React Native.

Using react-native-fs

The react-native-fs library provides file system access for downloading and saving files directly to the device.

bash npm install react-native-fs

Downloading a File

javascript import RNFS from 'react-native-fs'; const downloadFile = async () => { const path = `${RNFS.DocumentDirectoryPath}/report.pdf`; const result = await RNFS.downloadFile({ fromUrl: 'https://example.com/report.pdf', toFile: path, }).promise; console.log('Downloaded to:', path); };

Tracking Download Progress

javascript RNFS.downloadFile({ fromUrl: url, toFile: path, progress: (res) => { const percent = (res.bytesWritten / res.contentLength) * 100; setDownloadProgress(percent); }, });

Saving Images to the Gallery

For image files specifically, the CameraRoll module or libraries like react-native-cameraroll allow saving downloaded images directly to the device’s photo gallery.

Requesting Storage Permissions

On Android, saving files to certain directories requires explicit storage permissions, which must be requested before attempting the download.

Opening Downloaded Files

Once downloaded, files can be opened using libraries like react-native-file-viewer, allowing users to view PDFs or documents directly within the app.

Conclusion

Implementing file downloads with progress tracking and proper permission handling allows React Native applications to offer offline access to important documents, reports, and media content.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators