Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

Deploying to Heroku

Heroku is a cloud platform as a service (PaaS) supporting several programming languages.

Prerequisites

  • A Gatsby project set up. (Need help creating one? Follow the Quick Start)
  • A Heroku account
  • The Heroku CLI installed

Instructions

You can use the Heroku buildpack static to handle the static files of your site.

Set the heroku/node.js and heroku-buildpack-static buildpacks on your application.

You can optionally add the buildpacks to app.json if you want to take advantage of the Heroku platform API

Heroku will automatically detect and run the build script from your package.json which should already look like this:

Finally, add a static.json file in the root of your project to define the directory where your static assets will be. You can check all the options for this file in the heroku-buildpack-static configuration.

The following configuration will give you a good start point in line with Gatsby’s suggested approach to caching.

Limitations

Heroku doesn’t support advanced features like SSR, DSG, or Image CDN. You can get all features and faster builds by signing up to Gatsby Cloud.

Start building today on Netlify!
Edit this page on GitHub
© 2023 Gatsby, Inc.