deploy a React app
React JS

How to deploy a React app on a production

deploy a React app

Hi, Are you looking for the answer of how to deploy a React app on a production? Then you can read this tutorial. In this tutorial, I will explain everything in detail about the deployment of a React application.

Deploying a React app to production/server is not that much difficult as people think. I will show you how can you easily do this task.

Let’s get started.

Deploy a React app on production

The First thing that you have to do is declare the domain name in the package.json file like the given example.

package.json:

{
  "name": "your-app-name", /*Don't copy this line. You already have this*/
  "homepage": "https://dheerajverma.in/test_server",
}

When you open your package.json file, you will see the code something like the above-given code. So set the domain name accordingly and go-ahead for the next steps.

You don’t need to write “/test_server” if you want to deploy a react app on the live server (to the main domain). It is just a directory name that you will need to mention in case you want to upload your app inside a directory after the domain name.

For example:https://dheerajverma.in/test_server” contains the directory name in the URL so in this case, we will keep the same thing in our package.json file.

Now run the given command to create a build and copy all the files from the build folder and upload it on your server.

Build Command:

npm run build

That’s it ! You are done.

Recommended – How to run React Project locally on the static server after build

Conclusion:

In this tutorial, I have explained about react js production deployment. That might be helpful for anyone looking for deploy react app to production. Still, need any help? Ask in the comments below. Thanks for visiting.

Author

I am a Full Stack Web Developer. I have more than 8 years of experience in the web design and development industry.

Leave a Reply

Your email address will not be published. Required fields are marked *