{"id":15457481,"url":"https://github.com/rishi-raj-jain/edgio-dotenv-vault-nuxt-example","last_synced_at":"2025-04-01T12:24:28.857Z","repository":{"id":104875418,"uuid":"584641467","full_name":"rishi-raj-jain/edgio-dotenv-vault-nuxt-example","owner":"rishi-raj-jain","description":"An integration example of Dotenv Vault with Edgio and Nuxt.js","archived":false,"fork":false,"pushed_at":"2023-01-05T17:34:51.000Z","size":345,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-12T13:40:00.407Z","etag":null,"topics":["caching","dotenv","dotenv-vault","edgio","guide","nuxt"],"latest_commit_sha":null,"homepage":"https://rishi.app/blog/using-dotenv-vault-with-edgio-and-nuxt-js","language":"Vue","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/rishi-raj-jain.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":"2023-01-03T06:10:19.000Z","updated_at":"2023-01-05T17:32:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e964d66-9080-47fc-8bf1-57f1757243f7","html_url":"https://github.com/rishi-raj-jain/edgio-dotenv-vault-nuxt-example","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"ddf8bfe3166f3c9f9058fe2344dffeac8f2cbf39"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rishi-raj-jain","download_url":"https://codeload.github.com/rishi-raj-jain/edgio-dotenv-vault-nuxt-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246637216,"owners_count":20809570,"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","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":["caching","dotenv","dotenv-vault","edgio","guide","nuxt"],"created_at":"2024-10-01T22:45:42.201Z","updated_at":"2025-04-01T12:24:28.840Z","avatar_url":"https://github.com/rishi-raj-jain.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using Dotenv Vault with Edgio and Nuxt.js\n\nLearn how to make Edgio, Nuxt.js, and Dotenv Vault work together in a simple web app. This tutorial assumes you are already familiar with .env files and know [how to sync them](https://www.dotenv.org/docs/tutorials/sync).\n\n## Initialize a Nuxt(2) App\n\n```bash\nnpx create-nuxt-app edgio-dotenv-vault-nuxt-example\n```\n\n## Install Edgio CLI\n\n```bash\nnpm i -g @edgio/cli\n```\n\n## Integrate Edgio with Nuxt(2)\n\n```bash\nedgio init\n```\n\n## Install dotenv-vault\n\n```bash\n# Install as dep and not devDep\nnpm install dotenv-vault\n```\n\n## Update nuxt.config.js to use dotenv-vault\n\n```js filename='nuxt.config.js'\nrequire(\"dotenv-vault-core\").config()\n\nexport default {\n  // Auto import components: https://go.nuxtjs.dev/config-components\n  components: true,\n  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules\n  buildModules: [[\"@edgio/nuxt/module\", { edgioSourceMaps: true }]],\n}\n```\n\n## Update edgio.config.js to include .env.vault\n\n```js\n\"use strict\"\n\nmodule.exports = {\n  connector: \"@edgio/nuxt\",\n\n  // Set to true to include all packages listed in the dependencies property of package.json when deploying to Edgio.\n  includeNodeModules: true,\n\n  // Allows you to include additional resources in the bundle that is deployed to Edgio’s serverless JS workers.\n  // Keys are globs, value can be a boolean or string. This is typically used to ensure that resources\n  // that need to be dynamically required at runtime such as build manifests for server-side rendering\n  // or other config files are present in the cloud.\n  includeFiles: {\n    \".env.vault\": true,\n  },\n  \n}\n```\n\n## Run dotenv-vault new\n\nOpen terminal, enter your project’s root directory (where you keep your .env file), and run dotenv-vault new.\n\n```bash\nnpx dotenv-vault new\n```\n\nNote: **Picked verbatim from [dotenv.org](https://www.dotenv.org/docs/tutorials/sync#:~:text=Let%E2%80%99s%20get%20started.-,Run%20dotenv%2Dvault%20new,-Open%20terminal%2C%20enter)**\n\n## Run dotenv-vault login\n\nNext, authenticate your machine by running dotenv-vault login.\n\n```bash\nnpx dotenv-vault login\n```\n\nNote: **Picked verbatim from [dotenv.org](https://www.dotenv.org/docs/tutorials/sync#:~:text=Run%20dotenv%2Dvault%20login)**\n\n## Push your .env to the dotenv account\n\nReturn one last time to terminal and run dotenv-vault push.\n\nThis will securely push your .env file to dotenv-vault. Each time you change your .env file, run dotenv-vault push.\n\n```bash\nnpx dotenv-vault push\n```\n\nCongratulations 🎉, you just pushed (and secured) your first .env file in dotenv-vault.\n\nNote: **Picked verbatim from [dotenv.org](https://www.dotenv.org/docs/tutorials/sync#:~:text=12%20package.json-,Run%20dotenv%2Dvault%20push,-Return%20one%20last)**\n\n## Build the vault before running dev, build and production mode\n\nMake sure you are logged in and in sync with your Vault first then run npx dotenv-vault build from CLI in your project root.\n\nThis will build an encrypted .env.vault file that serves as a unique identifier for your project in Dotenv.\n\nInside it you will find the public keys for every environment you have setup and must be committed to source.\n\n```bash\nnpx dotenv-vault build\n```\n\nNote: **Picked verbatim from [dotenv.org](https://www.dotenv.org/docs/integrations/vercel/nuxtjs#:~:text=Example.-,Build%20the%20Vault,-Make%20sure%20you)**\n\n## Fetch the dotenv-vault keys\n\nWith the Vault successfully built, you now can fetch the .env.vault decryption keys for each environment in the Vault project.\n\nRunning npx dotenv-vault keys production, for example, will return the production key and so will development and ci respectively.\n\n```bash\nnpx dotenv-vault keys production\nremote:   Listing .env.vault decryption keys... done\n\ndotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production\n```\n\nNote: **Picked verbatim from [dotenv.org](https://www.dotenv.org/docs/integrations/vercel/nuxtjs#:~:text=dotenv%2Dvault%20build-,Fetch%20the%20keys,-With%20the%20Vault)**\n\n## Okay, what just happened?\n\nSo now realize that you've created three files:\n- .env: The file containing all your secret variables that you pushed to dotenv-vault via npx dotenv-vault push. This file is **not** to be pushed in git commit(s).\n\n- .env.me: That contains the key that uniquely identifies the user of the dotenv-vault project. This file is **not** to be pushed in git commit(s).\n\n- .env.vault: The file that contains the hashes to dotenv-vault's four mode: development, ci, staging and production.  This file is **to be pushed** in git commit(s).\n\n- You probably still haven't realized that dotenv-vault has stages of secrets. For example, look at the gray button on the top right corner in the screenshot below that says 'development'.\n \n![dotenv-vault example repo](https://a.storyblok.com/f/117912/2200x628/3880d64ef2/dotenv-vault.png)\n\nTo get keys for the **development** environment, one needs to run:\n\n```bash\nnpx dotenv-vault keys development\nremote:   Listing .env.vault decryption keys... done\n\ndotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development\n```\n\n\n## Requirements to run dotenv-vault\n\nWhat you get above is what we'll be referred to as **DOTENV_KEY** in the guide. To ensure dotenv-vault properly, in any mode, you'd require the **DOTENV_KEY** environment variable set, and the **.env.vault** file present in the root directory.\n\n\n## Using dotenv-vault during edgio dev (Edgio's dev mode)\n\n### Using .env at the root directory\n\nCreate a .env in your system which contains the following:\n\n```env\n# .env\n\nDOTENV_KEY=dotenv://:key_XXXX@dotenv.org/vault/.env.vault?environment=development\n```\n\nand then run the edgio's dev mode via:\n\n```bash\nedgio dev\n```\n\n### Setting the variable with the CLI command\n\n```bash\nDOTENV_KEY=dotenv://:key_XXXX@dotenv.org/vault/.env.vault?environment=development edgio dev\n```\n\n## Using dotenv-vault during edgio build (Edgio's build mode)\n\n### Using .env at the root directory\n\nCreate a .env in your system which contains the following:\n\n```env\n# .env\n\nDOTENV_KEY=dotenv://:key_XXXX@dotenv.org/vault/.env.vault?environment=development\n```\n\nand then run the edgio's build mode via:\n\n```bash\nedgio build\n```\n\n### Setting the variable with the CLI command\n\n```bash\nDOTENV_KEY=dotenv://:key_XXXX@dotenv.org/vault/.env.vault?environment=development edgio build\n```\n\n## Deploy To Edgio\n\n- To use dotenv-vault while deploying to Edgio, if you need the variables during the build time, deploy with:\n\n```bash\nDOTENV_KEY=dotenv://:key_XXXX@dotenv.org/vault/.env.vault?environment=development edgio deploy\n```\n\nelse just deploy with:\n\n```bash\nedgio deploy\n```\n\n## Using dotenv-vault during runtime (server-side)\n\nTo use the dotenv-vault during the **runtime** with Edgio, add an environment variable by following the guide [here](https://docs.edg.io/guides/basics/environments#creating-and-editing-environment-variables) named **DOTENV_KEY**.\n\n![Example DOTENV_KEY added to Edgio's environment](https://a.storyblok.com/f/117912/3024x1724/f9bca82f4c/loggedinss.png)\n\n## References\n\n- [https://www.dotenv.org/docs/integrations/vercel/nuxtjs](https://www.dotenv.org/docs/integrations/vercel/nuxtjs)\n- [https://www.dotenv.org/docs/tutorials/sync](https://www.dotenv.org/docs/tutorials/sync)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frishi-raj-jain%2Fedgio-dotenv-vault-nuxt-example/lists"}