Config.Config<string>The default host a bare-port client shorthand resolves against — an Effect Config
(EFFECT_PM_CLIENT_HOST) defaulting to "localhost". In dev nothing is set → localhost; in
production set it (EFFECT_PM_CLIENT_HOST=api.myapp.com) and every protocolHttp(3009) /
protocolWebsocket(3009) / connect(tag, …(port)) becomes …://api.myapp.com:3009/rpc — no
NODE_ENV branching, just "did they configure a host".
export const const clientHost: Config.Config<string>const clientHost: {
parse: (provider: ConfigProvider.ConfigProvider, pathPrefix?: Path) => Effect.Effect<T, ConfigError>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
The default host a bare-port client shorthand resolves against — an Effect
Config
(EFFECT_PM_CLIENT_HOST) defaulting to "localhost". In dev nothing is set → localhost; in
production set it (EFFECT_PM_CLIENT_HOST=api.myapp.com) and every protocolHttp(3009) /
protocolWebsocket(3009) / connect(tag, …(port)) becomes …://api.myapp.com:3009/rpc — no
NODE_ENV branching, just "did they configure a host".
clientHost: import ConfigConfig.interface Config<out T>A recipe for extracting a typed value T from a ConfigProvider.
When to use
Use to describe typed configuration that can be parsed from a provider or
yielded inside Effect.gen.
Details
Key members:
parse(provider, pathPrefix?) – runs the config against a specific provider.
The optional path prefix is the logical scope accumulated from outer
Config.nested calls.
- Yieldable – can be yielded inside
Effect.gen, which automatically
resolves the current ConfigProvider from the context.
- Pipeable – supports
.pipe(Config.map(...)) etc.
Config<string> = import ConfigConfig.function string(
name?: string
): Config.Config<string>
Creates a config for a single string value.
When to use
Use when reading a single string env var or config key.
Details
Shortcut for Config.schema(Schema.String, name).
Example (Reading a string config)
import { Config, ConfigProvider, Effect } from "effect"
const host = Config.string("HOST")
const provider = ConfigProvider.fromUnknown({ HOST: "localhost" })
// Effect.runSync(host.parse(provider)) // "localhost"
string(
"EFFECT_PM_CLIENT_HOST",
).Pipeable.pipe<Config.Config<string>, Config.Config<string>>(this: Config.Config<string>, ab: (_: Config.Config<string>) => Config.Config<string>): Config.Config<string> (+21 overloads)pipe(import ConfigConfig.const withDefault: <"localhost">(defaultValue: "localhost") => <A>(self: Config.Config<A>) => Config.Config<"localhost" | A> (+1 overload)Provides a fallback value when the config fails due to missing data.
When to use
Use when you need to make a config key optional with a sensible default.
Gotchas
Only applies when the error is a SchemaError caused exclusively by
missing data (missing keys, undefined values). Validation errors (wrong
type, out of range) still propagate.
Example (Defaulting a missing port)
import { Config, ConfigProvider, Effect } from "effect"
const port = Config.number("port").pipe(Config.withDefault(3000))
const provider = ConfigProvider.fromUnknown({})
// Effect.runSync(port.parse(provider)) // 3000
withDefault("localhost"));