Create an API using Node & Express and Host on Heroku for Free

Host API For Free

Here are the steps to be followed to get the API running on the Server.

  1. npm init to create a package.json file
  2. install packeages
    • "dependencies": { "cors": "^2.8.5", "express": "^4.18.1" }, "engines": { "node": "16.13.2" }
  3. Crete index.js file for the express to run on server
  4. add the json file and import it on index.js file
  5. create Procfile
    • simply add web: node index.js
  6. Now it's time to set the Heroku CLI to deploy our api live. For more details on heroku cli please watch this video wihtout skip:
  7. Once Heroku cli setup simply login using heroku login, then type the following commands to host api live on server
    1. git init
    2. git add .
    3. git commit -m "your msg"
    4. heroku create
    5. git push heroku master

Subscribe - Thapa Technical