Optionalopts: Partial<EnvFactoryOpts>Optional configuration:
Env instance for the detected platform
const env = envFactory();
// Get single value
const apiKey = env.get('API_KEY');
// Get multiple values with Result
const config = env.gets('DB_HOST', 'DB_PORT', 'DB_NAME');
if (config.isOk()) {
const { DB_HOST, DB_PORT, DB_NAME } = config.unwrap();
}
// Listen for changes
env.onSet((key, value) => {
console.log(`${key} changed to ${value}`);
}, 'API_KEY'); // Optional: filter by specific keys
Creates a platform-appropriate environment variable interface.
Automatically detects the runtime environment (Node.js, Deno, browser, Cloudflare Workers) and returns an Env instance with platform-specific implementations. Supports preset values, change notifications, and type-safe multi-key retrieval.