Steps

  1. Create new web project

  2. Initialize the folder with git

    git init .
  1. Initialize it with npm
    npm init
  1. Add engines and start script in package.json

  2. Create account on heroku.com

  3. Install heroku cli

    npm i -g heroku-cli
  1. To create app:
    heroku apps:create <appname>
  1. To add addons:
    heroku addons:add <addonname>:<planname>
    eg:
    heroku addons:add heroku-postgresql:hobby-dev
  1. Create config:

    5.1) Change from hardcoded port to 'process.env.PORT'

    5.2) Change from hardcoded db_url to 'process.env.DATABASE_URL'

  2. To push to heroku

    git push heroku master

After connecting github repository and heroku:

    git push origin master