SvelteKit + Varlock


Home

Comparison of the ways to read env vars in a SvelteKit/Vite app. Rendered on the server.

Cells marked ❌ would cause a build error if uncommented in the source — hover the source to see the commented-out line.

varlock vs native JS globals

itemENV (varlock)process.envimport.meta.env
GREETINGhellohello
VITE_PREFIXED_ITEMvite-prefixedvite-prefixedvite-prefixed
SECRET_ITEM (sensitive)✅ varlock detects leak❌ would leak without varlock🚨 silently returns undefined
BAD_VAR (not in schema)✅ varlock triggers an error🚨 Silently returns undefined 🚨 Silently returns undefined