Suppose you’re on a train, trying to upload some important files for a meeting. But the network keeps dropping every time the train goes through a tunnel.
That’s annoying, right?
This is what so many people deal with every day when they are trying to upload file online from their phone.
The problem is, most upload systems assume your internet will stay perfect the whole time. But that almost never happens. Even a tiny network drop can make the entire upload fail.
In this guide, I’ll walk you through how to build upload components in React that can handle these real-world issues, even when your users are switching between mobile data and WiFi, facing temporary disconnections, or just have weak signals.
And it doesn’t matter if you’re making a photo-sharing app, a document portal, or anything that needs file uploads; if your upload system can handle unstable networks well, your users are going to have a much smoother experience.
Key Takeaways
- Chunked uploads break large files into smaller parts so the upload doesn’t break every time the network drops.
- Auto-retry makes the app try again on its own when the connection drops.
- Saving upload progress makes sure users don’t lose everything if they close the tab or the browser crashes.
- Detecting network changes helps your app adjust smoothly when someone moves from WiFi to mobile data.
- Proper error handling gives users clear, helpful messages instead of confusing failures.
Understanding the Problem
Before we talk about how to fix all this, let’s first understand why standard file uploads fail on unreliable networks.
Traditional uploads send the whole file in one go. If the internet drops for even a second, the entire upload fails, and you have to start over. So if you’re trying to upload a 50MB video on a weak connection, you’ll probably end up retrying again and again.
And mobile users deal with even more issues:
- Switching networks: Moving from WiFi to mobile data breaks the connection.
- Low bandwidth: Slow connections increase the chances of timeouts.
- Battery optimisation: Mobiles sometimes limit background activity to save battery.
- Tunnel or low-signal zones: Even tiny drops in signal can interrupt the upload.
According to research on mobile network reliability, users on mobile data often experience short drop-outs or unstable connectivity. So your upload system needs to be designed with this real-world behaviour in mind.
Core Concepts for Resilient Uploads
Now that you know why uploads fail, let’s look at the simple ideas that make them more reliable on unstable networks.
1. Chunked File Uploads
Chunking means breaking a large file into small parts (usually 5–10MB). Each part uploads independently, so if one fails, only that part needs to retry, not the entire file.
Why this helps:
- You don’t lose all progress when something fails.
- Great for large files on slow or unstable networks.
- You can pick up from the last uploaded chunk.
- Uses less memory on both the client and server.
2. Automatic Retry Logic
Instead of failing immediately, a reliable upload flow automatically retries the request by waiting a little longer each time. This gives temporary network issues a chance to settle without the user doing anything.
3. Save Upload Progress
By storing upload progress in the browser, users can close the tab or browser and continue later. This is especially helpful for huge files that take hours to upload.
Building Your Upload File Online Component
At this point, you know why uploads fail and what makes them reliable. Now let’s put it all together and build a React upload component that handles real-world network issues.
You can build chunking, retries, and resumable uploads on your own, but it takes time and a lot of edge-case work. It’s usually easier to use a library that already supports these features.
I’m using Filestack in this example because it includes chunking and resumable uploads out of the box, but the same concepts will work with any tool you prefer.
Step 1: Setting Up Your Project
First, install the filestack package:
| npm install filestack-js |
Step 2: Create a Simple Upload File Online Component
Now let’s build a basic React component that can upload files.
Create a new file like ResilientUpload.jsx in your src folder and add the following code there.
| import React, { useState } from “react”; import * as filestack from “filestack-js”; function ResilientUpload() { const [uploadedFiles, setUploadedFiles] = useState([]); // store uploaded file info const client = filestack.init(“YOUR_API_KEY”); // replace with your API key const openPicker = () => { const options = { accept: [“image/*”, “video/*”], // allowed file types maxFiles: 10, // limit number of files onUploadDone: (res) => { console.log(“Upload complete:”, res); setUploadedFiles(res.filesUploaded); // update uploaded file list }, }; client.picker(options).open(); // open Filestack picker popup }; return ( <div className=”upload-container”> <h2>Upload Your Files</h2> <button onClick={openPicker} className=”upload-button”> Choose Files to Upload </button> {/* Show the uploaded files */} {uploadedFiles.length > 0 && ( <div className=”uploaded-files”> <h3>Successfully Uploaded</h3> <ul> {uploadedFiles.map((file, index) => ( <li key={index}> {file.filename} ({(file.size / 1024 / 1024).toFixed(2)} MB) </li> ))} </ul> </div> )} </div> ); } export default ResilientUpload; |
What this component does:
- Shows a button that opens the Filestack picker.
- User selects files.
- Filestack uploads them using chunking + retries internally.
- onUploadDone gives you the final file details.
- The uploaded files are shown on screen.
Step 3: Add Simple UI Styling
Now let’s add some basic styling.
Create a new CSS file named upload.css in the same src folder and paste this inside it:
| .upload-container { max-width: 600px; margin: 40px auto; padding: 20px; font-family: Arial, sans-serif; } .upload-button { background-color: #4CAF50; color: white; padding: 12px 24px; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; transition: background-color 0.3s; } .upload-button:hover { background-color: #45a049; } .uploaded-files { margin-top: 30px; padding: 15px; background-color: #e8f5e9; border-radius: 4px; } .uploaded-files ul { list-style: none; padding: 0; } .uploaded-files li { padding: 8px 0; border-bottom: 1px solid #c8e6c9; } .uploaded-files li:last-child { border-bottom: none; } |
Make sure you also import this CSS at the top of your ResilientUpload.jsx:
| import ‘./upload.css’; |
Step 4: Use the Component in Your App
Now we need to show the upload component in the browser.
Open App.jsx and import your upload component:
| import ResilientUpload from ‘./ResilientUpload’; |
Then render it:
| function App() { return ( <div> <ResilientUpload /> </div> ); } export default App; |
Step 5: Run the Project
Start your React app:
| npm run dev |
Then open your browser and go to: http://localhost:5173
You should now see your upload UI. Just click the button, choose your files, and the upload will work smoothly, even if your internet drops for a moment.
