Deployment.io

Deploy a Gatsby app on AWS


Deployment.io builds your Gatsby app from its repository and serves it from Amazon S3 and CloudFront in your own AWS account.

Before you start

  • The app is in a GitHub, GitLab or Bitbucket repository that's connected to Deployment.io. See Adding a Repository.

Deployment

  1. Create a new Static site on Deployment.io.
  2. Select your app's repository.
  3. Build command: npm run build (runs gatsby build).
  4. Publish directory: public.
  5. Single-page app: No.
  6. Root directory: leave it empty unless the app lives in a subfolder of the repository (a monorepo). Then enter that folder.
  7. Choose the Environment and click Deploy static site.

Your site is available at the CloudFront URL shown in the dashboard once the build finishes. See Adding Custom Domains and Automatic Deployment on Git Push.

How the build runs

Deployment.io installs the app's dependencies before the build command, with the package manager its lockfile names — npm (package-lock.json), Yarn (yarn.lock) or pnpm (pnpm-lock.yaml). A packageManager field in package.json is honoured. So the build command is only the build itself — don't add an install step.

Builds run on Node.js 22, and package.json must be at the top of the repository or of the Root directory.

Environment variables

The environment's variables are available to the build. Gatsby puts only variables with the GATSBY_ prefix into the code that runs in the browser.

Anything in a static site's build is public — never put a secret there.

Routing

Gatsby writes each page as <path>/index.html, which is how Deployment.io serves a page's address, so pages load as they are.

With Single-page app set to No, an address with no page shows the site's 404.html with a 404 status, and an address without a trailing slash (such as /about) redirects to the one with it (/about/). If the site was already deployed with Yes, change the setting on its Settings tab; it applies on the next deploy.