You’ll often see files called .env in projects… but what are environment variables, and why should…
You’ll often see files called .env in projects…
but what are environment variables, and why should you never share them?”
Examples:
* database password
* API keys
* secret tokens
We don’t write these directly in code because:
* code can be shared
* pushed to GitHub
* or seen by others
So instead, we store them in a .env file.
Inside a .env file, you’ll see things like as shown
Your app reads this value at runtime,
but the value is not hardcoded in your code.
This makes apps secure and flexible.
Now the important rule:
👉 Never push your .env file to GitHub.
That’s why it’s added to .gitignore.
So how does this work in production?
When deploying on platforms like Vercel or Netlify,
you don’t upload the .env file.
Instead, you manually add environment variables
inside their dashboard settings.
Those platforms securely inject the values
when your app runs.
That’s why environment variables are so important.
Comments
Comments from the original post on Instagram
No comments yet
