All together
Deploy NEXT.JS on HEROKU
Deploying to HEROKU is simple.
-
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.
-
Make sure index.js works.
-
Add Code to .gitignore
node_modules/ .next/ *.log
-
Modify package.json
"scripts": { "dev": "next", "build": "next build", "start": "next start -p $PORT", "heroku-postbuild": "npm run build" },
-
Push to Github
Create a new repository in your browser on Github. Then type the following in your root directory.
-
Deploy on Heroku
- Open your browser and sign into Heroku
- Navigate to the “Dashboard”
- Select your newly created app
- Click “Deploy”
- Under “Deployment Method” select “Github”
- Add repository name
({username}/{repositoryname})
- Click “Search”
- Click “Connect”
- Select Branch
- Click “Deploy Branch”
- Click “View”