envil envil Docs

Envil

Type-safe environment validation with composable runtime boundaries.

Envil composes target-aware environment fragments and exposes two lazy Effect programs:

  • appEnv.server materializes server, client, and shared definitions.
  • appEnv.client materializes client and shared definitions.
import {
  client,
  createEnv,
  redacted,
  server,
  shared,
  url,
} from "@ayronforge/envil";

export const appEnv = createEnv(
  shared({
    APP_NAME: "My App",
  }),
  server({
    DATABASE_URL: redacted(url),
  }),
  client(
    {
      APP_URL: url,
    },
    {
      runtimeEnv: import.meta.env,
      prefix: "VITE_",
    },
  ),
);

Nothing is read, decoded, or resolved until the selected Effect runs. Fragments can be authored independently and combined with extendEnv; when definitions overlap, the last complete definition wins.