An Elixir library for reading and casting configuration from environment variables and other sources at runtime.
Confex is an Elixir library designed to simplify reading and using application configuration from environment variables and other external sources at runtime. It solves the problem of managing dynamic configuration in production environments by providing type casting, default values, and an adapter-based system for flexible value fetching.
Elixir developers building applications that require runtime configuration, especially those deploying with tools like Docker, Kubernetes, or Distillery, and teams using Phoenix or Ecto who need environment-based settings.
Developers choose Confex for its clean integration with Elixir's configuration system, built-in type casting, and explicit approach to runtime configuration without external dependencies, making it a reliable and lightweight alternative to manual environment variable handling.
Useful helper to read and use application configuration from environment variables.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows fetching configuration from any source by implementing the Confex.Adapter behavior, with built-in adapters for system environment variables and file-based secrets, as detailed in the README's adapter section.
Automatically casts string environment variables to Elixir types like integers, booleans, and lists using tuples such as {:system, :integer, "ENV_NAME"}, reducing manual parsing boilerplate.
Designed for dynamic environments like Docker and Kubernetes, enabling configuration changes without recompilation, which is ideal for modern deployment workflows.
Provides examples and macros for seamless integration with Phoenix and Ecto, using their init/2 callbacks to load configuration at startup, as shown in the README.
For applications with only a few environment variables, using Confex's tuple syntax and macros can introduce more complexity than necessary compared to plain System.get_env calls.
While flexible, creating custom adapters requires implementing the Confex.Adapter behavior, which might be a hurdle for teams needing quick integration with uncommon configuration sources.
If environment variables are missing and no defaults are provided, Confex will raise exceptions at runtime, potentially causing application crashes if not carefully managed, as implied by the error examples in the README.