Dotvault for Gatsby

Dotvault for Gatsby sites.

Gatsby picks its env file based on NODE_ENV, so .env.development and .env.production are both live and neither is the one you are looking at. Anything prefixed GATSBY_ gets baked into the client bundle. Dotvault opens both files at once and labels every GATSBY_ variable as client-exposed, so the public side of that line is marked in the file you are editing. Put something under GATSBY_ that can only be a secret and it warns outright, gitignored file or not, because the bundle gets built either way.

What you get

  • Detects Gatsby from package.json.
  • Labels GATSBY_ variables as client-exposed, so what ends up in the bundle is visible as you edit.
  • Warns when a GATSBY_ value can only be a secret: a Stripe or Anthropic secret key, a GitHub or Slack token, an AWS access key id, or a key named SECRET, PASSWORD or PRIVATE_KEY. Publishable and public API keys are left alone, because that is what the prefix is for.
  • Flags values matching a known secret pattern in any file git can see, whatever the variable is called.
  • Compare .env.development and .env.production in one view.

Known environment variables

Dotvault recognises these variables when you open a Gatsby project and surfaces helpful descriptions and warnings in the editor. Gatsby is detected via gatsby in package.json.

  • GATSBY_

    Client-exposed variable (Gatsby)

  • ENABLE_GATSBY_REFRESH_ENDPOINT

    Enable content refresh webhook

  • GATSBY_TELEMETRY_DISABLED

    Disable Gatsby telemetry

  • CI

    Signal CI environment to Gatsby

  • NODE_ENV

    Node environment (development/production)

Official Gatsby docs: www.gatsbyjs.com/docs