{"id":19852646,"url":"https://github.com/luanbitar/gatsby-env-variables","last_synced_at":"2026-03-08T02:04:34.036Z","repository":{"id":36465893,"uuid":"225918358","full_name":"luanbitar/gatsby-env-variables","owner":"luanbitar","description":"Gatsby plugin to provide custom environment variables in client-side","archived":false,"fork":false,"pushed_at":"2023-10-11T00:08:05.000Z","size":35,"stargazers_count":18,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-29T20:24:15.718Z","etag":null,"topics":["env","environment","environment-variables","environments","gatsby","gatsby-plugin","gatsbyjs","variables"],"latest_commit_sha":null,"homepage":"https://www.gatsbyjs.org/packages/gatsby-env-variables/?=env","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luanbitar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"luanbitar"}},"created_at":"2019-12-04T17:11:25.000Z","updated_at":"2025-05-09T21:23:02.000Z","dependencies_parsed_at":"2023-10-11T02:03:50.932Z","dependency_job_id":null,"html_url":"https://github.com/luanbitar/gatsby-env-variables","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":"0.31999999999999995","last_synced_commit":"58fa6c3f4fcfad231f0d0227939a40360b5d2da6"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/luanbitar/gatsby-env-variables","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanbitar%2Fgatsby-env-variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanbitar%2Fgatsby-env-variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanbitar%2Fgatsby-env-variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanbitar%2Fgatsby-env-variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luanbitar","download_url":"https://codeload.github.com/luanbitar/gatsby-env-variables/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luanbitar%2Fgatsby-env-variables/sbom","scorecard":{"id":601460,"data":{"date":"2025-08-11","repo":{"name":"github.com/luanbitar/gatsby-env-variables","commit":"710f0dde4e103ae166998f632b4fc9051c5dbb17"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/luanbitar/gatsby-env-variables/npmpublish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npmpublish.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/luanbitar/gatsby-env-variables/npmpublish.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/npmpublish.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 2/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Creative Commons Zero v1.0 Universal: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 4 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T00:32:57.205Z","repository_id":36465893,"created_at":"2025-08-21T00:32:57.205Z","updated_at":"2025-08-21T00:32:57.205Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30242404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T00:58:18.660Z","status":"online","status_checked_at":"2026-03-08T02:00:06.215Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["env","environment","environment-variables","environments","gatsby","gatsby-plugin","gatsbyjs","variables"],"created_at":"2024-11-12T14:03:50.183Z","updated_at":"2026-03-08T02:04:34.014Z","avatar_url":"https://github.com/luanbitar.png","language":"JavaScript","funding_links":["https://github.com/sponsors/luanbitar"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"illustration.svg\" width=\"300\"\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/gatsby-env-variables\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/gatsby-env-variables.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/gatsby-env-variables\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/gatsby-env-variables.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e gatsby-env-variables \u003c/h1\u003e\n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\n  Webpack feature to provide your custom environment variables in client side\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Use `BUILD_ENV` to chose wich environment file to load and `THEME` to chose theme variables together\n\u003c/p\u003e\n\n## Install\n\n`$ npm i gatsby-env-variables`\n\nor\n\n`$ yarn add gatsby-env-variables`\n\n## How to use\n\nAdd the plugin to your `gatsby-config.js`.\n\n```javascript\nmodule.exports = {\n  plugins: [\n    `gatsby-env-variables`\n  ]\n}\n```\n\nCreate your's `environment.js` files inside `env/` folder, on root of your project, file `index.js` will be the file with variables shared between multiple environments, if you chose other env, these variables will be merged\n\n```bash\nproject/\n├── env/\n  ├── index.js\n  ├── development.js\n  ├── staging.js\n  └── production.js\n```\n\nindex.js\n```javascript\nmodule.exports = {\n  API_ROOT: \"example.com\",\n  CARDS: \"/cards\",\n}\n```\n\nstaging.js\n```javascript\nmodule.exports = {\n  API_ROOT: \"stg.example.com\",\n}\n```\n\nRun your yarn/npm script with `BUILD_ENV` variable to chose your environment, default selected is `development`\n\npackage.json\n\n```bash\nBUILD_ENV=staging yarn start\n```\n\n# Use in client-side\n\n## Global variables\n\n```javascript\n/* globals API_ROOT, CARDS */\n\nfunction Example() {\n  const cardsURL = API_ROOT + CARDS // stg.example.com/cards\n  fetch(cardsURL)\n}\n```\n\nIf you don't want to use `/* globals */` in each file, just create an empty `.eslintrc` file in your project folder. If you are using eslint, just disable the `no-undef` rule.\n\n## Importing variables\n\n```javascript\nimport { API_ROOT, CARDS } from \"gatsby-env-variables\"\n\nfunction Example() {\n  const cardsURL = API_ROOT + CARDS // stg.example.com/cards\n  fetch(cardsURL)\n}\n```\n# Using themes\n\nYou can have multiple themes, with multiple environments, just put your variables inside the name of theme, and use `THEME=example` on your running script\n\nstaging.js\n```javascript\nmodule.exports = {\n  API_ROOT: \"stg.example.com\",\n  dark: {\n    CARDS: \"/dark_cards\",\n  }\n}\n```\n\npackage.json\n\n```bash\nTHEME=dark BUILD_ENV=staging yarn start\n```\n\nUse in client-side\n\n```javascript\nfunction Example() {\n  const cardsURL = API_ROOT + CARDS // stg.example.com/dark_cards\n  fetch(cardsURL)\n}\n```\n\n## Nested Objects\n\nString values are not required, you can use nested objects too\n\nstaging.js\n```javascript\nmodule.exports = {\n  API: {\n    CARDS: \"/cards\"\n  }\n\n  dark: {\n    API_ROOT: \"darkexample.com\"\n  }\n}\n```\n\n## Async variables\n\nIf you have to put dynamic variables in you environment, like values coming from API or something like this, you can export an promise\n\nstaging.js\n```javascript\nmodule.exports = new Promise(async res =\u003e {\n  const ROOT_API = \"example.com\"\n  const CARDS = \"/cards\"\n\n  const response = await fetch(ROOT_API + CARDS)\n  const ACTIVE_CARDS = await response.json()\n\n  const envs = {\n    ROOT_API,\n    CARDS,\n    ACTIVE_CARDS,\n    dark: {\n      CARDS: \"/dark_cards\",\n    },\n    orange: {\n      CARDS: \"/orange_cards\",\n    },\n  }\n\n  res(envs)\n}) \n```\n\n\n# Options\n\n### `envFolderPath`\n\nThis options allows you to specify which folder will stay your `.env` files\n\nExample:\n\n```javascript\nmodule.exports = {\n  plugins: [\n    {\n      resolve: `gatsby-env-variables`,\n      options: {\n        envFolderPath: `src/env/`\n      }\n    }\n  ]\n}\n```\n\n```bash\nproject/\n├── src/\n  ├── env/\n    ├── index.js\n    ├── development.js\n    ├── staging.js\n    └── production.j\n```\n\nOr you can use this option to rename to `config/` folder too\n\nExample:\n\n```javascript\nmodule.exports = {\n  plugins: [\n    {\n      resolve: `gatsby-env-variables`,\n      options: {\n        envFolderPath: `config/`\n      }\n    }\n  ]\n}\n```\n\n```bash\nproject/\n├── config/\n  ├── index.js\n  ├── development.js\n  ├── staging.js\n  └── production.jn\n```\n\n## Further reading\n\nCheck out the [DefinePlugin section][1] of the Webpack config documentation for more information.\n\n[1]: https://webpack.js.org/plugins/define-plugin/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluanbitar%2Fgatsby-env-variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluanbitar%2Fgatsby-env-variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluanbitar%2Fgatsby-env-variables/lists"}