All modules:

Link copied to clipboard

Annotations you put on a config class. @ConfigSpec marks the class for the KSP processor, which generates its loader. The other annotations tune single fields: @Key renames the key, @Secret masks the value in reports and errors, @Convert plugs in a custom ValueConverter, and @Range, @Size, @NotBlank and @Pattern validate values.

Link copied to clipboard

The runtime every Konstant app needs. ConfigLoader reads values from a stack of ConfigSources in priority order, converts and validates them, and returns a ConfigResult: either the loaded config or every ConfigError found. ConfigLoader.explain also reports where each value came from. Konstant holds the loaded config for apps that want global access, and configField / field expose single values as property delegates.

Link copied to clipboard

JsonSource reads JSON config through kotlinx-serialization-json. Nested objects become dot-separated keys (server.port) and arrays of plain values become lists. Comments, trailing commas and a leading BOM are accepted.

Link copied to clipboard

Koin integration: config<T>() inside a Koin module registers the config held by Konstant as a single definition, so other definitions can inject it. Load the config before Koin resolves it.

Link copied to clipboard

Configs that change while the app runs. ReloadableConfig exposes the current config as a StateFlow, reloads it on demand, on a timer or when a ReloadableSource changes, and keeps the last good config when a reload fails. RemoteSource is a source your app fills from any remote config service (Firebase Remote Config, your own backend) by calling update.

Link copied to clipboard

Built-in sources for environment variables, .env files and .properties files, on every platform. Each source has companion factories: fromFile, fromResource and fromString. Resources are read from the classpath on the JVM, from assets on Android, from the main bundle on Apple platforms, and from files on Node and Linux.

Link copied to clipboard

Helpers for tests. MapSource is an in-memory source built from key-value pairs, so tests can load a config without files or environment variables.

Link copied to clipboard

TomlSource reads TOML config through ktoml. Tables become dot-separated keys (server.port) and arrays of plain values become lists. This module does not support wasmJs, because ktoml's wasm build is broken with Kotlin 2.3.

Link copied to clipboard

YamlSource reads YAML config through kaml. Mappings become dot-separated keys (server.port) and sequences of plain values become lists.