Package: effect
Module: ConfigProvider
Creates a ConfigProvider by parsing the string contents of a .env file.
When to use
Use when you already have the .env contents as a string, such as contents
fetched from a remote store or embedded in a test.
Details
Supports export prefixes, single/double/backtick quoting, inline comments,
and escaped newlines. Variable expansion (for example, ${VAR}) is disabled
by default; enable with { expandVariables: true }.
Literal empty strings are treated as missing values when loaded as values by
default. Pass { preserveEmptyStrings: true } to keep empty strings as
explicit values. Child discovery still reflects the keys present in the
parsed .env source.
Parsing is based on the dotenv / dotenv-expand algorithm.
Internally delegates to fromEnv with the parsed key-value pairs.
Example (Parsing .env contents)
import { ConfigProvider } from "effect"
const contents = `
HOST=localhost
PORT=3000
# this is a comment
`
const provider = ConfigProvider.fromDotEnvContents(contents)
See
fromDotEnv – loads a .env file from diskfromEnv – for raw environment variable accessSignature
declare const fromDotEnvContents: (lines: string, options?: { readonly expandVariables?: boolean | undefined; readonly preserveEmptyStrings?: boolean | undefined; }) => ConfigProvider
Since v4.0.0