Guides

Overview

Recipes for wiring @vlandoss/env in each runtime — Node, SPA, SSR — and for the patterns that come up once you compose schemas across files.

Each guide is a self-contained recipe. Start with the one that matches where your code runs.

By runtime

GuideWhen to use
Filesystem (loadConfig)Long-running Node/Bun/Deno server reading config files from disk.
SPA — dynamic importPure SPA built with Vite. Bundler emits one chunk per env; browser downloads the right one.
SPA — Vite plugin (#config)Pure SPA where you want each build artifact to contain only its env (max isolation).
SSR / SSGServer-rendered React app. Public values hydrate the browser via <EnvScript />.

By task

GuideWhen to use
Schema compositionShare a contract across server and client by inlining one schema() inside another.
Custom modes (staging, qa)Surface non-default Vite modes to browser code. Explains why the plugin is required.

How a guide is structured

Every guide follows the same shape:

  1. When to use it — 1–2 bullets so you know whether to keep reading.
  2. Minimal working snippet — copy-pasteable.
  3. What each piece does — short explanation per moving part.
  4. Tradeoffs / limits — when this recipe stops being a good fit.

Signatures and option tables live in the API reference, not in the guides.

On this page