Load environment variables from a .env file into the Elixir application environment for development and non-release deployments.
Dotenv for Elixir is a port of the popular dotenv library that enables Elixir applications to load configuration from `.env` files into the system environment. It simplifies development and deployment in environments like Heroku or Dokku where configuration is managed via environment variables, though it is not compatible with Elixir releases.
Elixir developers deploying to platforms like Heroku or Dokku that rely on environment variables for configuration, particularly those not using Elixir releases. It is also suited for development and testing environments where managing environment variables via files is convenient.
Developers choose Dotenv for Elixir because it provides a familiar, dotenv-style workflow for loading environment variables from files, integrates easily with non-release deployments, and offers both automatic loading and a serverless API for fine-grained control. Its ability to restrict usage to specific environments (e.g., dev and test) ensures it doesn't interfere with production setups.
A port of dotenv to Elixir
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically loads .env files into the system environment on OTP application start, eliminating manual export commands in development and testing.
Can be restricted to only :dev and :test in mix dependencies, preventing accidental use in production and aligning with non-release deployments.
Provides functions like load/1 to return variables as data structures, enabling programmatic inspection and fine-grained control without server overhead.
Dotenv.reload!/0 allows refreshing variables from .env files without restarting the application, speeding up development iterations.
Explicitly warned as incompatible with Elixir releases, a major limitation for modern deployment workflows using Distillery or similar tools.
Requires manual loading and Mix.Task.run('loadconfig') to use .env variables in application configuration, adding setup complexity compared to native Elixir config.
Variables are loaded at runtime, not compile time, which can conflict with Elixir's configuration system and limit use in early-stage validation.