What if your app's secret keys were accidentally shared with the whole world? Here's how to prevent that.
Why Environment variables and secrets in Supabase? - Purpose & Use Cases
Imagine you have to set up your app on multiple computers by typing passwords and keys every time you start it.
You write them down in your code or share them in chat messages.
It feels like leaving your house keys under the doormat for everyone to find.
Manually typing or storing secrets in code is slow and risky.
You might mistype a password or accidentally share it with others.
Changing a secret means updating many places, which is tiring and error-prone.
Environment variables and secrets let you store sensitive info safely outside your code.
Your app reads them automatically when it runs, so you never expose passwords in your files.
This keeps your secrets safe and makes updates easy.
const apiKey = 'my-secret-key'; // hardcoded in code
const apiKey = process.env.API_KEY; // loaded from environment variablesYou can safely manage and update sensitive data without touching your code, making your app more secure and flexible.
A developer deploys a Supabase app and sets the database password as a secret in the environment.
When the password changes, they update it once in the environment, and the app keeps working without code changes.
Manual secret handling risks leaks and mistakes.
Environment variables keep secrets safe outside code.
They simplify updates and improve security.