how to run react builed version

How to Run React Built Version

If you have developed a React app and built it using the npm run build command, you might be wondering how to run it locally or deploy it to a server. Here are some ways to do it:

Run Locally Using Serve

You can use the serve package to run your built React app locally. First, install it globally using npm install -g serve. Then, navigate to your app's build directory using the cd command. Finally, run serve -s build. This will serve your app at http://localhost:5000.

$ npm install -g serve
$ cd my-app/build
$ serve -s build

Deploy to a Server

If you want to deploy your built React app to a server, you can do it manually or use a service like Netlify or Heroku. Here are the steps for manual deployment:

  1. Copy the contents of your app's build directory to your server using FTP or SSH.
  2. Install a web server like Apache or Nginx on your server if it's not already installed.
  3. Create a virtual host or edit the default configuration file to serve your app's build directory.
  4. Restart your web server.

If you're using Netlify or Heroku, you can simply connect your app's Git repository and they will handle the deployment process for you.

Conclusion

Running a built React app is easy once you know how to do it. Whether you want to run it locally using serve or deploy it to a server, there are multiple ways to do it. Just choose the method that works best for you and follow the steps.

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe