Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.83 KB

README.md

File metadata and controls

59 lines (43 loc) · 1.83 KB

Next.js on Heroku

Deploy React-based universal web apps on Heroku.

Demo deployment from this repo:
https://nextjs.herokuapp.com

A custom Node/Express server is supported. Use it to:

  • combine a Node API with a Next/React UI
  • implement custom URL routes

▶️ Next with custom Express server

Requires

Production deployment

Once you have a Next app working locally, you may deploy it for public access.

  1. Add the heroku-postbuild hook to automatically build the Next app on each deployment:

    Merge this entry into package.json:

    {
      "scripts": {
        "heroku-postbuild": "next build"
      }
    }

    🌈 In February 2017, Next was fixed, so the Heroku build adapter is no longer required.

  2. Ensure the app is a git repo, ignoring local-only directories:

    git init
    (echo node_modules/ && echo .next/) >> .gitignore
  3. Create the Heroku app:

    heroku create $APP_NAME
  4. 🚀 Deploy:

    git add .
    git commit -m 'Next.js app on Heroku'
    git push heroku master
  5. ♻️ Deploy changes: add, commit, & push again.