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.
| item | ENV (varlock) | process.env | import.meta.env |
|---|---|---|---|
GREETING | hello | hello | |
VITE_PREFIXED_ITEM | vite-prefixed | vite-prefixed | vite-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 |