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
| Guide | When to use |
|---|---|
Filesystem (loadConfig) | Long-running Node/Bun/Deno server reading config files from disk. |
| SPA — dynamic import | Pure 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 / SSG | Server-rendered React app. Public values hydrate the browser via <EnvScript />. |
By task
| Guide | When to use |
|---|---|
| Schema composition | Share 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:
- When to use it — 1–2 bullets so you know whether to keep reading.
- Minimal working snippet — copy-pasteable.
- What each piece does — short explanation per moving part.
- Tradeoffs / limits — when this recipe stops being a good fit.
Signatures and option tables live in the API reference, not in the guides.
envName()
How @vlandoss/env detects the current environment name across Node, browsers, and Vite builds — including the subtlety with custom modes.
Filesystem (loadConfig)
Wire @vlandoss/env in a long-running server. Schema, per-environment config files on disk, and a typed env loaded at boot via loadConfig.