{"id":17014666,"url":"https://github.com/natoboram/load_env","last_synced_at":"2025-04-22T13:47:29.533Z","repository":{"id":257824181,"uuid":"871837819","full_name":"NatoBoram/load_env","owner":"NatoBoram","description":"A standalone implementation of Vite's loadEnv","archived":false,"fork":false,"pushed_at":"2025-03-25T14:19:32.000Z","size":352,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T15:41:33.879Z","etag":null,"topics":["dotenv","env","environment-variables","vite"],"latest_commit_sha":null,"homepage":"https://natoboram.github.io/load_env/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NatoBoram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yaml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["NatoBoram"],"patreon":"NatoBoram","custom":["https://paypal.me/NatoBoram/5"]}},"created_at":"2024-10-13T04:40:53.000Z","updated_at":"2025-03-02T03:14:59.000Z","dependencies_parsed_at":"2025-02-02T07:18:48.882Z","dependency_job_id":"abc6e847-4c4f-461e-aa6c-9f4d379de5f1","html_url":"https://github.com/NatoBoram/load_env","commit_stats":null,"previous_names":["natoboram/load_env"],"tags_count":2,"template":false,"template_full_name":"NatoBoram/gigachad.ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatoBoram%2Fload_env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatoBoram%2Fload_env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatoBoram%2Fload_env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatoBoram%2Fload_env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NatoBoram","download_url":"https://codeload.github.com/NatoBoram/load_env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250251536,"owners_count":21399830,"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":["dotenv","env","environment-variables","vite"],"created_at":"2024-10-14T06:25:39.560Z","updated_at":"2025-04-22T13:47:29.527Z","avatar_url":"https://github.com/NatoBoram.png","language":"TypeScript","funding_links":["https://github.com/sponsors/NatoBoram","https://patreon.com/NatoBoram","https://paypal.me/NatoBoram/5"],"categories":[],"sub_categories":[],"readme":"# `@natoboram/load_env`\n\n[![Node.js CI](https://github.com/NatoBoram/load_env/actions/workflows/node.js.yaml/badge.svg)](https://github.com/NatoBoram/load_env/actions/workflows/node.js.yaml) [![GitHub Pages](https://github.com/NatoBoram/load_env/actions/workflows/github-pages.yaml/badge.svg)](https://github.com/NatoBoram/load_env/actions/workflows/github-pages.yaml) [![Dependabot Updates](https://github.com/NatoBoram/load_env/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/NatoBoram/load_env/actions/workflows/dependabot/dependabot-updates) [![GitHub Downloads](https://img.shields.io/github/downloads/natoboram/load_env/total?logo=github\u0026color=0969da)](https://github.com/natoboram/load_env/releases) [![NPM Downloads](https://img.shields.io/npm/dt/%40natoboram/load_env?logo=npm\u0026color=CB3837)](https://www.npmjs.com/package/@natoboram/load_env)\n\nA standalone implementation of Vite's `loadEnv`.\n\n## Installation\n\n`@natoboram/load_env` is available on [npmjs](https://www.npmjs.com/package/@natoboram/load_env), [GitHub Packages](https://github.com/NatoBoram/load_env/pkgs/npm/load_env), and [GitHub Releases](https://github.com/NatoBoram/load_env/releases).\n\n```sh\npnpm i @natoboram/load_env\n```\n\n## Usage\n\nThe `loadEnv` function loads environment variables from the current directory's `.env` files. `NODE_ENV` has to be set in the environment and will not be picked up from the filesystem.\n\nIf `NODE_ENV` is not set, it defaults to `development`.\n\nEnvironment variables are loaded in the following order:\n\n1. `.env.${NODE_ENV}.local`\n2. `.env.${NODE_ENV}`\n3. `.env.local`\n4. `.env`\n\nAdditional functions are provided for the type safety of environment variables. See the [documentation](https://natoboram.github.io/load_env) for the full list of available functions.\n\n```ts\nimport {\n\tenvBool,\n\tenvFloat,\n\tenvInt,\n\tenvString,\n\tenvUrl,\n\tenvUuid,\n\tloadEnv,\n\tmaybeEnvBool,\n\tmaybeEnvFloat,\n\tmaybeEnvInt,\n\tmaybeEnvString,\n\tmaybeEnvUrl,\n\tmaybeEnvUuid,\n} from \"@natoboram/load_env\"\nimport type { UUID } from \"crypto\"\n\nloadEnv()\n\nexport const EXAMPLE_BOOLEAN: boolean = envBool(\"EXAMPLE_BOOLEAN\")\nexport const EXAMPLE_FLOAT: number = envFloat(\"EXAMPLE_FLOAT\")\nexport const EXAMPLE_INT: number = envInt(\"EXAMPLE_INT\")\nexport const EXAMPLE_STRING: string = envString(\"EXAMPLE_STRING\")\nexport const EXAMPLE_URL: URL = envUrl(\"EXAMPLE_URL\")\nexport const EXAMPLE_UUID: UUID = envUuid(\"EXAMPLE_UUID\")\n\nexport const OPTIONAL_BOOL: boolean | undefined = maybeEnvBool(\"EXAMPLE_BOOL\")\nexport const OPTIONAL_FLOAT: number | undefined = maybeEnvFloat(\"EXAMPLE_FLOAT\")\nexport const OPTIONAL_INT: number | undefined = maybeEnvInt(\"EXAMPLE_INT\")\nexport const OPTIONAL_STR: string | undefined = maybeEnvString(\"EXAMPLE_STR\")\nexport const OPTIONAL_URL: URL | undefined = maybeEnvUrl(\"EXAMPLE_URL\")\nexport const OPTIONAL_UUID: UUID | undefined = maybeEnvUuid(\"EXAMPLE_UUID\")\n```\n\nNon-optional functions support a default value as the second argument.\n\n```ts\nexport const EXAMPLE_STRING: string = envString(\"EXAMPLE_STRING\", \"default\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatoboram%2Fload_env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatoboram%2Fload_env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatoboram%2Fload_env/lists"}