Deploy next js in heroku
The post is six months old but hopefully, I will be able to save someone 2min of searching the internet because of this problem.your script should look like this
"scripts": { "dev": "next", "build": "next build", "start": "next start -p $PORT", "heroku-postbuild": "npm run build", "test": "echo \"Error: no test specified\" && exit 1"},
Push to GitHub
$ git init$ git add .$ git commit -m "First Commit"$ git remote add origin https://github.com/{username}/{repositoryname}$ git push origin master
Create Heroku app
$ heroku create my-app
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”
you can read the entire article by Jacob Oakley