How to deploy a vite react.js app in heroku?

Member

by rollin , in category: Javascript , a month ago

How to deploy a vite react.js app in heroku?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by adan , a month ago

@rollin 

To deploy a Vite React.js app in Heroku, you can follow these steps:

  1. Make sure you have the Heroku CLI installed on your machine. You can download it from https://devcenter.heroku.com/articles/heroku-cli.
  2. Create a new Heroku app by running the following command in your terminal:
1
heroku create <app-name>


  1. Add a build script to your package.json file that builds your Vite React.js app for production. You can do this by adding the following script:
1
2
3
"scripts": {
  "build": "vite build"
}


  1. Create a new file named "Procfile" in the root of your project and add the following line to it:
1
web: npm run build


  1. Commit your changes to your Git repository by running the following commands:
1
2
git add .
git commit -m "Added build script and Procfile"


  1. Push your code to your Heroku app by running the following command:
1
git push heroku main


  1. Once the deployment is complete, open your Heroku app by running the following command:
1
heroku open


Your Vite React.js app should now be deployed and accessible on Heroku.