Skip to main content
Version: 2.x

Introduction to ZIO Config

ZIO Config is a ZIO library for reading application configuration. It extends the Config and ConfigProvider types from ZIO. You describe the settings your program needs once, as a value of type Config[A], and then load that description from any source: HOCON, JSON, YAML, TOML, XML, environment variables, maps or AWS Parameter Store.

Production Ready CI Badge Sonatype Releases Sonatype Snapshots javadoc ZIO Config

Key Featuresโ€‹

  • Many sources. Read flat or nested settings from HOCON, JSON, YAML, TOML, XML, maps, the environment and more, and layer them. See Config providers.
  • Automatic derivation. Build a config description from a case class or sealed trait with one call. See Derivation.
  • Validation. Check values with Config#validate, custom parsers or refined types. See Validation.
  • Documentation generation. Produce a table of every setting, its format and its description. See Documentation generation.
  • Error accumulation. Report every problem in one go, not only the first. See Errors.
  • Integrations. Works with enumeratum, cats, scalaz, pureconfig and AWS. See Integrations.

Installationโ€‹

Add the core module to build.sbt:

// ZIO Config core: config descriptors and readers (JVM)
libraryDependencies += "dev.zio" %% "zio-config" % "4.1.3"

Add the other modules you need, with the same version:

ModuleAdds
zio-config-magnoliaAutomatic derivation of descriptions from case classes and sealed traits
zio-config-typesafeHOCON and JSON sources
zio-config-yamlYAML sources
zio-config-tomlTOML sources
zio-config-xmlXML sources (experimental)
zio-config-awsAWS Parameter Store, through the AWS SDK for Java
zio-config-zio-awsAWS Parameter Store, through ZIO AWS
zio-config-refinedValidation with refined types
zio-config-catscats data types and instances
zio-config-scalazscalaz data types and instances
zio-config-enumeratumenumeratum enums
zio-config-pureconfigReuse of pureconfig readers

zio-config, zio-config-cats, zio-config-scalaz and zio-config-enumeratum are also published for Scala.js and Scala Native; use %%% instead of %% there. The other modules are JVM only.

Where to Startโ€‹

  1. Getting Started adds the dependencies and loads a first config.
  2. The tutorials teach the concepts step by step: modelling a configuration with case classes and sealed traits, loading it in a ZIO application, and layering HOCON with environment variables.
  3. The how-to guides solve specific tasks, such as setting the config provider for an application, reading secrets and testing configuration.
  4. The reference pages describe every part of the API, starting with Config descriptors.

Migratingโ€‹

Examplesโ€‹

More complete examples are in the examples module of the repository.

ZIO Chat

๐Ÿ”ฅ Ignite your ZIO journey with ZIO Chat! ๐Ÿ”ฅ Ready to unravel the intricacies of ZIO? As your trusty sidekick, I'm here to light the way. No matter if you're wandering through functional forests or traversing effectful landscapes, I've got answers to keep you on track. Your ZIO adventure starts here โ€“ ask me anything and let's explore together!