Table of Contents

**@arolariu/website**


@arolariu/website / types / TypedEnvironment

Type Alias: TypedEnvironment<SiteEnv, ApiEnv>

TypedEnvironment<SiteEnv, ApiEnv> = Readonly<SiteEnvironmentVariables<SiteEnv> & ApiEnvironmentVariables<ApiEnv> & AuthEnvironmentVariables & MetadataEnvironmentVariables>

Defined in: types/typedEnv.ts:311

Combines all environment variable types into a single type-safe interface.

Type Parameters

SiteEnv

SiteEnv extends "production" | "development"

The site environment ("production" | "development")

ApiEnv

ApiEnv extends "production"

The API environment (currently only "production")

Remarks

Type Safety: Enforces correct environment variable combinations at compile time. For example, TypedEnvironment<"production", "production"> automatically infers:

  • SITE_NAME: "arolariu.ro"
  • SITE_URL: "https://arolariu.ro"
  • API_URL: "https://api.arolariu.ro"

Composition: Merges four distinct environment variable categories:

  1. Site: Frontend-specific configuration (name, URL)
  2. API: Backend API configuration (endpoint, name)
  3. Auth: Authentication credentials (Clerk, JWT, Resend)
  4. Metadata: Build-time information (timestamp, commit SHA, CDN flag)

Immutability: The resulting type is deeply readonly, preventing runtime modifications.

Usage Context: Used as the return type for environment configuration loaders, ensuring all code consuming environment variables has compile-time type safety.

Design Rationale: Separating variable categories allows:

  • Independent testing of each category
  • Clear documentation of variable purposes
  • Easier extension (add new categories without breaking existing code)

Example

// Production environment with full type inference
const prodEnv: TypedEnvironment<"production", "production"> = {
  SITE_ENV: "PRODUCTION",
  SITE_NAME: "arolariu.ro", // Automatically inferred!
  SITE_URL: "https://arolariu.ro",
  API_ENV: "PRODUCTION",
  API_NAME: "arolariu-api",
  API_URL: "https://api.arolariu.ro",
  NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: "pk_live_...",
  CLERK_SECRET_KEY: "sk_live_...",
  API_JWT: "eyJ...",
  RESEND_API_KEY: "re_...",
  TIMESTAMP: "2025-11-26T12:00:00Z",
  COMMIT_SHA: "a1b2c3d",
  USE_CDN: true
};

See

  • SiteEnvironmentVariables
  • ApiEnvironmentVariables
  • AuthEnvironmentVariables
  • MetadataEnvironmentVariables