Environment variables are like little notes your computer programs read to know important settings, such as passwords or API keys, without hardcoding them in the code.
Click to reveal answer
beginner
Why should secrets not be hardcoded in your code?
Hardcoding secrets risks exposing them if the code is shared or leaked. Using environment variables keeps secrets safe and separate from the code.
Click to reveal answer
intermediate
How does Supabase help manage environment variables and secrets?
Supabase lets you securely store environment variables and secrets in its dashboard, so your apps can access them safely without exposing sensitive data.
Click to reveal answer
beginner
What is a common real-life example of environment variables?
Like a house key you keep safe and use only when needed, environment variables store keys or passwords your app uses to connect to services without showing them openly.
Click to reveal answer
intermediate
What is the difference between environment variables and secrets?
Environment variables are any settings your app reads from outside the code. Secrets are a special kind of environment variable that hold sensitive info like passwords or tokens.
Click to reveal answer
Why should you use environment variables for secrets?
ATo keep sensitive data out of the code and secure
BTo make the code run faster
CTo store images and videos
DTo replace database tables
✗ Incorrect
Environment variables keep secrets safe by not embedding them directly in the code.
Where do you typically set environment variables in Supabase?
AIn the Supabase dashboard under project settings
BInside the app's main code file
CIn the browser's console
DOn your phone's settings
✗ Incorrect
Supabase dashboard provides a secure place to set environment variables for your project.
Which of these is NOT a good practice for managing secrets?
AUsing secret managers
BUsing environment variables
CHardcoding passwords in code
DRestricting access to secrets
✗ Incorrect
Hardcoding passwords is unsafe and should be avoided.
What kind of information is stored as secrets?
AUser interface colors
BFont styles
CPublic blog posts
DAPI keys and passwords
✗ Incorrect
Secrets include sensitive info like API keys and passwords.
How does using environment variables improve app security?
ABy encrypting the entire app
BBy separating sensitive data from code and controlling access
CBy storing all data in the cloud
DBy making the app load faster
✗ Incorrect
Separating secrets from code helps prevent accidental leaks and controls who can see sensitive info.
Explain how environment variables and secrets work together in a Supabase project.
Think about how your app gets passwords without showing them in code.
You got /4 concepts.
Describe why it is important to keep secrets out of your code and how environment variables help.
Imagine sharing a photo without showing your house keys.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of environment variables in Supabase?
easy
A. To display data on the website
B. To write SQL queries directly in the dashboard
C. To store important information like API keys outside the code
D. To create user accounts automatically
Solution
Step 1: Understand environment variables
Environment variables hold data like API keys or URLs outside the code to keep it safe and flexible.
Step 2: Identify their use in Supabase
Supabase uses environment variables to keep secrets safe and avoid hardcoding sensitive info.
Final Answer:
To store important information like API keys outside the code -> Option C
What will be the output if SUPABASE_URL is set to https://xyz.supabase.co and SUPABASE_ANON_KEY is not set?
medium
A. https://xyz.supabase.co undefined
B. undefined undefined
C. https://xyz.supabase.co null
D. Error: SUPABASE_ANON_KEY not found
Solution
Step 1: Check environment variable values
SUPABASE_URL is set to a URL string, but SUPABASE_ANON_KEY is missing, so it is undefined.
Step 2: Understand console.log output
Logging both variables prints the URL string and undefined for the missing key.
Final Answer:
https://xyz.supabase.co undefined -> Option A
Quick Check:
Missing env vars print undefined [OK]
Hint: Missing env vars show as undefined in logs [OK]
Common Mistakes:
Expecting an error when env var is missing
Assuming missing vars print null
Confusing undefined with empty string
4. You added a secret API_SECRET in the Supabase dashboard but your app still logs undefined when accessing process.env.API_SECRET. What is the most likely cause?
medium
A. You must include the secret in your code manually
B. The secret name is case-insensitive and should be lowercase
C. Supabase does not support environment variables
D. You forgot to restart the app after adding the secret
Solution
Step 1: Understand environment variable loading
Environment variables are loaded when the app starts, so changes require a restart to take effect.
Step 2: Identify the cause of undefined
If the app logs undefined, it likely did not reload the updated environment variables after adding the secret.
Final Answer:
You forgot to restart the app after adding the secret -> Option D
Quick Check:
Restart app to load new env vars [OK]
Hint: Restart app after adding secrets to load them [OK]
Common Mistakes:
Thinking secret names are case-insensitive
Believing Supabase doesn't support env vars
Trying to hardcode secrets in code
5. You want to securely use a third-party API key in your Supabase Edge Function without exposing it in client code. Which approach is best?
hard
A. Store the API key as a secret in Supabase dashboard and access it via process.env inside the Edge Function
B. Hardcode the API key directly in the Edge Function code
C. Send the API key from the client app to the Edge Function on every request
D. Publish the API key in a public GitHub repo for easy access
Solution
Step 1: Understand secure storage of secrets
Secrets like API keys should never be hardcoded or exposed publicly to avoid leaks.
Step 2: Use Supabase secrets in Edge Functions
Storing the API key as a secret in the dashboard and accessing it via process.env inside the Edge Function keeps it secure and hidden from clients.
Final Answer:
Store the API key as a secret in Supabase dashboard and access it via process.env inside the Edge Function -> Option A
Quick Check:
Use secrets in server code, not client [OK]
Hint: Keep API keys in secrets, access only server-side [OK]
Common Mistakes:
Hardcoding keys in code risking exposure
Sending keys from client risking interception
Publishing keys publicly causing leaks
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.