ConfigProvider that is compatible with the Convex runtime, where process.env is not enumerable. Confect sets it automatically for every function that runs in the Convex runtime—queries, mutations, actions, and HTTP API handlers—so Effect’s Config module works out of the box.
Node actions are the exception. They run in the Node.js runtime, where process.env behaves like an ordinary object, so they use Effect’s default ConfigProvider.fromEnv instead. Reading environment variables works the same way in both runtimes.
Reading environment variables
UseConfig from Effect to read Convex environment variables in your function handlers.
confect/settings.impl.ts
Config.string, Config.number, Config.boolean, Config.withDefault, Config.option, and Config.nested, among others.
Limitations
Config operations that enumerateprocess.env are unsupported in the Convex runtime, and fail with an Unsupported config error. This covers every combinator that resolves a collection of keys rather than a single one:
Config.array,Config.chunk, andConfig.hashSetConfig.hashMap
Config.array is the surprising member of that list, since it looks like a way to read one comma-separated variable. Effect resolves a sequence by first looking for indexed keys (ALLOWED_ORIGINS[0], ALLOWED_ORIGINS[1], and so on), which requires enumeration, so it fails before it can fall back to splitting a delimited value.
To read a delimited variable, parse it yourself:
process.env in the Node.js runtime. Avoid depending on that if the handler might later move to the Convex runtime.
Custom config provider
TheConvexConfigProvider module is exported from @confect/server. ConvexConfigProvider.make() takes the same options as Effect’s ConfigProvider.fromEnv, and both are optional—calling it with no arguments returns the provider Confect already installs for you.
To use a custom provider in a function handler, pass it to
Effect.withConfigProvider.
confect/settings.impl.ts