Overview - Environment variables ($env)
What is it?
Environment variables in Svelte are special values that store configuration data outside your code. They help your app know things like API keys or URLs without hardcoding them. SvelteKit uses the $env module to access these variables safely during build or runtime. This keeps sensitive info secure and makes your app flexible across different setups.
Why it matters
Without environment variables, you'd have to write secret keys or settings directly in your code. This is risky because anyone can see them, and changing settings means editing code and redeploying. Environment variables let you change important data without touching code, making apps safer and easier to manage in different places like development, testing, or production.
Where it fits
Before learning environment variables, you should understand basic Svelte app structure and how to run Svelte projects. After this, you can learn about deployment and configuration management to see how environment variables help apps adapt to different servers or cloud platforms.