All together


All together

Deploy NEXT.JS on HEROKU

Deploying to HEROKU is simple.

  1. Create a project Open your terminal and navigate to the location you would like to save the project then type the following in your terminal.

  2. Make sure index.js works.

  3. Add Code to .gitignore

    node_modules/
    .next/
    *.log
    
  4. Modify package.json

    "scripts": {
      "dev": "next",
      "build": "next build",
      "start": "next start -p $PORT",
      "heroku-postbuild": "npm run build"
    },
    
  5. Push to Github

    Create a new repository in your browser on Github. Then type the following in your root directory.

  6. Deploy on Heroku

    1. Open your browser and sign into Heroku
    2. Navigate to the “Dashboard”
    3. Select your newly created app
    4. Click “Deploy”
    5. Under “Deployment Method” select “Github”
    6. Add repository name ({username}/{repositoryname})
    7. Click “Search”
    8. Click “Connect”
    9. Select Branch
    10. Click “Deploy Branch”
    11. Click “View”