Skip to content

Gatsby plugin to allow system environment variables to be made available to client-side scripts

License

Notifications You must be signed in to change notification settings

chadly/gatsby-plugin-env-variables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

768418e Â· Dec 22, 2022

History

15 Commits
May 20, 2021
May 20, 2021
Apr 30, 2020
May 20, 2021
Jan 23, 2019
Apr 30, 2020
Jan 23, 2019
Jul 14, 2020
Dec 21, 2022
Dec 22, 2022

Repository files navigation

Gatsby Environment Variables Plugin

A Gatsby plugin to allow system environment variables to be made available to client-side scripts.

By default, Gatsby only makes system environment variables prefixed with GATSBY_ available to client scripts. Using this plugin, you can make any arbitrary environment variable available at runtime.

Install

npm install gatsby-plugin-env-variables

How to use

In gatsby-config.js:

module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-env-variables`,
      options: {
        allowList: ["MY_VAR", "MY_OTHER_VAR"]
      },
    },
  ],
}

This will make MY_VAR & MY_OTHER_VAR available at runtime in your app by accessing process.env.MY_VAR or process.env.MY_OTHER_VAR.