When to Use Secrets / Environment Variables
API Keys
Third-party service credentials
Configuration
Feature flags, URLs, settings
Secrets
Sensitive data that shouldn’t be in code
Environment-Specific
Different values for dev/staging/prod
In AI Prompts
Tell the AI to use secrets / environment variables but never add the secret to the prompt: Bad example:Secrets / Environment Variables by Backend Type
How you manage environment variables depends on which backend system you’re using.Which backend am I using? If you see a “Database” button in the preview header, you’re on Liquid Backend. Otherwise, you’re using Supabase. See Backend Systems.
Liquid Backend
With Liquid Backend, environment variables are split between frontend and backend:Frontend Variables
For variables used in your React Native code:Supabase Environment Variables
Supabase
Supabase credentials are managed through OAuth:Using Public Secrets / Environment Variables in Frontend
Accessing Variables
All frontend environment variables are specified in app.json and accessed the same way:With Default Values
Best Practices
Never hardcode secrets
Never hardcode secrets
API keys, passwords, and tokens should always be in environment variables, not in your code.
Use descriptive names
Use descriptive names
Use clear names like
STRIPE_PUBLIC_KEY instead of KEY1Separate frontend and backend secrets
Separate frontend and backend secrets
Only public keys belong in frontend environment variables. Server-side secrets go in your backend.
Document required variables
Document required variables
Keep track of which environment variables your app needs for deployment.
Troubleshooting
Variable returns undefined
Variable returns undefined
- Check the variable name matches exactly (case-sensitive)
- Ensure you saved after adding the variable
- Reload the preview after changes
API key not working
API key not working
- Verify the key is correct (copy-paste from source)
- Check if the key has proper permissions/scopes
Secret exposed in code
Secret exposed in code
- If its not a “public secret”, contact support in Natively
Related
Backend Systems
Understand Liquid Backend vs Supabase
Supabase Integration
Full Supabase setup guide