How to Update a React App on a Live Server (VPS) – The Easiest Way

Keeping your React app updated on a live server doesn’t have to be a headache. In this quick guide, I’ll walk you through the simplest way to update your React-based web app on a VPS. Whether you’re using a DigitalOcean droplet, AWS EC2, or any other Linux-based server, this method will work smoothly.

Let’s dive right in. 👇


🔧 Step 1: Build Your React App

First, open your terminal in the project root directory and run the following command:

npm run build

This will create an optimized production build of your app inside the build/ folder.


📦 Step 2: Prepare for Deployment

Archive all the contents inside the build/ folder (not the folder itself). You can use any zip tool or terminal command like this:

zip -r react-build.zip build/*

This creates a zipped file containing all your static assets that are ready to go live.


🔐 Step 3: Connect to Your VPS

Use SSH to log into your VPS:

ssh root@your-server-ip

Replace your-username and your-server-ip with your actual VPS credentials.


📁 Step 4: Navigate to Your Web Directory

Now, go to the directory where your current React app is hosted. For example:

cd /new/www/html

🧹 Step 5: Clear Old Files

Remove all existing files from the directory to avoid conflicts with your new build:

rm -rf *

⚠️ Be careful! This command deletes everything in the directory. Make sure you’re in the right folder before running it.


⬆️ Step 6: Upload the New Build

Use your preferred FTP/SFTP client (like FileZilla or WinSCP) to upload the react-build.zip file into your VPS directory (e.g., /new/www/html).

Alternatively, you can use SCP from your local machine:

scp react-build.zip your-username@your-server-ip:/var/www/html


📂 Step 7: Unzip the Build

Once uploaded, go back to your VPS terminal and unzip the file:

unzip Archive.zip

Then, you can delete the zip file to keep things clean:

rm Archive.zip

🎉 Done! Enjoy the Updated App

That’s it! Your updated React app is now live on your VPS. Just refresh your browser and enjoy the changes. If you’re using Nginx or Apache, make sure it’s already set up to serve the React app from this directory.


Bonus Tips 💡

  • Always take a backup before deleting files.
  • Use tools like PM2 or Nginx for better performance and reliability.
  • Consider automating this process with Git and CI/CD in the future.

Have questions or want to automate deployments? Let’s chat in the comments below!

Happy coding! ✨