Varlock turns your
.env into a validated, typed schema — a .env.schema annotated with JSDoc-style decorators (@type, @required,
@sensitive). Mochi renders every page on the server on each request, so there's nothing to prerender or statically inline: you load() the schema
once at boot, then read live values through the typed ENV proxy during SSR.
Point package.json's varlock.loadPath at your schema, then do this once at the top of your server entry — index.ts, before
Mochi.serve() — so config is validated before the server boots and every request can read it:
The index.ts tab below shows the full wiring, including patchGlobalConsole() to keep secrets out of your logs. See the decorator DSL at
varlock.dev.
These values were parsed, coerced, and validated by varlock during this page's SSR render.
| Variable | Value | Reads as |
|---|---|---|
{item.key}
{#if item.isSensitive} |
{#if item.isSensitive}
••••••••
{:else}
{item.value}
{/if}
|
{item.jsType} |
DEMO_API_PORT arrives as a JavaScript number ({config.apiPort}), and
DEMO_API_URL already has its {'${DEMO_API_PORT}'} reference expanded to
{config.apiUrl}. The @sensitive key never leaves the server — it's masked before it reaches the props, and patchGlobalConsole() keeps it
out of your logs.