How to deploy on Heroku?

We recommend you read the Heroku documentation for Node.js.

First, we need to tell Heroku to install the devDependencies of the project (to be able to launch npm run build):

heroku config:set NPM_CONFIG_PRODUCTION=false

Also, we want our application to listen on the host and run in production mode:

heroku config:set HOST=
heroku config:set NODE_ENV=production

You should see this in your Heroku dashboard (Settings section):

nuxt config vars Heroku

Then, we tell Heroku to launch npm run build via the heroku-postbuild script in our package.json:

"scripts": {
  "dev": "nuxt",
  "build": "nuxt build",
  "start": "nuxt start",
  "heroku-postbuild": "npm run build"

Finally, we can push the app on Heroku with:

git push heroku master

VoilĂ ! Your Nuxt.js application is now hosted on Heroku!

Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!