{"id":17917529,"url":"https://github.com/simplesmiler/nuxt-env-shim","last_synced_at":"2025-08-01T14:02:30.877Z","repository":{"id":66096891,"uuid":"198715140","full_name":"simplesmiler/nuxt-env-shim","owner":"simplesmiler","description":null,"archived":false,"fork":false,"pushed_at":"2019-07-25T20:15:15.000Z","size":104,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-09T09:08:15.696Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplesmiler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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}},"created_at":"2019-07-24T21:58:34.000Z","updated_at":"2020-01-27T14:54:29.000Z","dependencies_parsed_at":"2023-05-06T18:47:11.743Z","dependency_job_id":null,"html_url":"https://github.com/simplesmiler/nuxt-env-shim","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"abd55fd1818b63ce9a05fde087886b78476e22eb"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/simplesmiler/nuxt-env-shim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesmiler%2Fnuxt-env-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesmiler%2Fnuxt-env-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesmiler%2Fnuxt-env-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesmiler%2Fnuxt-env-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplesmiler","download_url":"https://codeload.github.com/simplesmiler/nuxt-env-shim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplesmiler%2Fnuxt-env-shim/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268240279,"owners_count":24218355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"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":[],"created_at":"2024-10-28T20:07:42.444Z","updated_at":"2025-08-01T14:02:30.841Z","avatar_url":"https://github.com/simplesmiler.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"**nuxt-env-shim** inject env vars for your Nuxt app at runtime\n\n## Why\n\nSee https://github.com/nuxt/nuxt.js/issues/5100\n\nThis module, heavily inspired by [samtgarson/nuxt-env](https://github.com/samtgarson/nuxt-env), makes runtime environmental\nvariables injection work both in unviversal in SPA mode. It also provides shims for some other nuxt modules to work with\nruntime environmental variables (currently, only [@nuxtjs/axios](https://github.com/nuxt-community/axios-module)).\n\n⚠ **WARNING**: As with the `config.env` option in Nuxt config, environment variables used in `nuxt-env-shim` are exposed client side, so if you store secrets use the `secret` config option. Read more below. ⚠\n\n## Usage\n\n`nuxt-env-shim` injects your environment variables into your Nuxt app using `this.$env`.\n\n_**N.B.** If currently use Nuxt's `config.env` option, fear not—`nuxt-env` includes those env vars in the `$env` object._\n\n### Get Setup\n\n1. Install the dependency:\n```bash\nyarn add nuxt-env-shim\n```\n\n2. Add to your `nuxt.config.js` and configure:\n```js\n// nuxt.config.js\n\n// Tell nuxt-env which env vars you want to inject\nmodules: [\n  ['nuxt-env-shim', {\n    keys: [\n      'TEST_ENV_VAR', // Basic usage—equivalent of { key: 'TEST_ENV_VAR' }\n      { key: 'OTHER_ENV_VAR', default: 'defaultValue' }, // Specify a default value\n      { key: 'THIRD_ENV_VAR', secret: true }, // Only inject the var server side\n      { key: 'ANOTHER_ENV_VAR', name: 'MY_ENV_VAR' }, // Rename the variable\n    ]\n  }]\n]\n```\n\n#### Options\n\nEnv vars can be injected in a basic way, just by specifying a string in the `keys` option.\nWhen the provided var is an object, it can have the following attributes:\n\n##### `key`\n\u003e required\n\nThe name of the environment variable by which it can be accessed in `process.env`\n\n##### `default`\n\nA default value for the env var in case it's not present in `process.env`.\n\n##### `secret`\n\u003e default: `false`\n\nWhen true, this key will only be present server side.\n\n##### `name`\n\nChange the name of the env var that gets injected. e.g.: `{ key: 'API_URL', name: 'API_ENDPOINT' }` will read `process.env.API_URL` and add it as `$env.API_ENDPOINT`\n\n#### Shims\n\nShims can be enabled by setting corresponding boolean flags in the `shimModules` option:\n\n```js\nmodules: [\n  ['nuxt-env-shim', {\n    shimModules: {\n      // exposes runtime environment variables API_HOST, API_PORT, API_PREFIX, API_URL and API_URL_BROWSER\n      // and instructs axios module correspondingly\n      axios: true,\n    },\n  }],\n]\n```\n\nShims are provided for some other nuxt modules. This is how you can enable shim for the axios module:\n\n\n### Use in your application\n\n- Use `this.$env` in your components:\n```js\n// any-component.vue\n\nexport default {\n  computed: {\n    testValue () { return this.$env.TEST_VALUE }\n  }\n}\n```\n\n- and in your Nuxt context\n```js\n// any-component.vue\n\nexport default {\n  asyncData ({ app }) {\n    console.log(app.$env.TEST_VALUE)\n  }\n}\n```\n\n- and in your store:\n```js\n// store/index.js\n\nexport const mutations = {\n  storeEnv (commit) {\n    const val = this.$env.TEST_VALUE\n    commit('testValue', val)\n  }\n}\n```\n\n### Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/simplesmiler/nuxt-env-shim. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n### Thanks\n\n- Many thanks to [Evan You](https://github.com/yyx990803) and the [VueJS](https://github.com/vuejs) team for sustaining such a vibrant and supportive community around Vue JS\n- Many thanks also [Alex Chopin](https://github.com/alexchopin), [Sébastien Chopin](https://github.com/Atinux), [Pooya Parsa](https://github.com/pi0) and the other [Nuxt](https://github.com/nuxt) contributors for creating this awesome library\n- Many thanks also [Sam Garson](https://github.com/samtgarson) for creating the original nuxt-env\n\n### License\n\nThe module is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplesmiler%2Fnuxt-env-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplesmiler%2Fnuxt-env-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplesmiler%2Fnuxt-env-shim/lists"}