Overview
The Incidents App uses environment variables to configure both the mobile app and web dashboard. This guide covers all required and optional environment variables for each platform.Mobile App Environment Variables
The mobile app uses environment variables prefixed withEXPO_PUBLIC_ to make them accessible in the client.
Required Variables
Create a.env file in the mobile directory:
mobile/.env
Variable Reference
The URL of your Supabase project. Find this in your Supabase project settings under API.Format:
https://[project-id].supabase.coThe anonymous (public) API key for your Supabase project. This key is safe to use in client-side code.Location: Supabase Dashboard → Settings → API → anon public
Usage in Code
Environment variables are accessed in the mobile app:mobile/src/services/supabase.ts
EAS Build Configuration
For production builds with EAS, add environment variables toeas.json:
mobile/eas.json
Alternatively, use Expo’s encrypted secrets for sensitive values:
Web Dashboard Environment Variables
The web dashboard uses Next.js environment variables. Client-side variables must be prefixed withNEXT_PUBLIC_.
Required Variables
Create a.env.local file in the web directory:
web/.env.local
Variable Reference
The URL of your Supabase project.Format:
https://[project-id].supabase.coThe anonymous (public) API key for your Supabase project.Location: Supabase Dashboard → Settings → API → anon public
Usage in Code
Client-Side
web/lib/supabase.ts
Server-Side
web/lib/supabase-server.ts
Environment Files
Next.js supports multiple environment files:| File | Description | Loaded When |
|---|---|---|
.env | Default environment variables | All environments |
.env.local | Local overrides (not committed) | All environments |
.env.development | Development-specific variables | npm run dev |
.env.production | Production-specific variables | npm run build && npm start |
Vercel Configuration
When deploying to Vercel, add environment variables in the project settings:Open project settings
Navigate to your project in Vercel Dashboard → Settings → Environment Variables
Add variables
Add each required variable:
- Key:
NEXT_PUBLIC_SUPABASE_URL - Value: Your Supabase project URL
- Environment: Production, Preview, Development
Getting Supabase Credentials
To find your Supabase credentials:Open Supabase Dashboard
Visit app.supabase.com and select your project.
The
anon key is safe to use in client-side code. It respects Row Level Security (RLS) policies.Security Best Practices
Never Expose Service Role Key
Supabase provides two types of API keys:- anon (public): Safe for client-side use, respects RLS
- service_role: Full database access, NEVER use in client code
Environment Variable Checklist
Use
EXPO_PUBLIC_ prefix for Expo mobile appUse
NEXT_PUBLIC_ prefix for Next.js web appNever commit
.env.local or .env files with secretsUse
anon key for client-side, not service_roleRotate keys if accidentally exposed
Use environment-specific values for staging vs production
Rotating Keys
If you accidentally expose your anon key:Multi-Environment Setup
For staging and production environments:Mobile (EAS)
mobile/eas.json
Web (Vercel)
Create different environment variable sets in Vercel:- Production: Used for
mainbranch - Preview: Used for pull request deployments
- Development: Used for local development
Troubleshooting
Variables Not Loading
Mobile app:- Restart the Metro bundler:
npx expo start --clear - Ensure variables start with
EXPO_PUBLIC_ - Check
.envfile is inmobile/directory
- Restart Next.js dev server
- Ensure variables start with
NEXT_PUBLIC_for client-side - Check
.env.localfile is inweb/directory
Build-Time vs Runtime
Environment variables are embedded at build time. If you change variables:- Mobile: Rebuild the app with EAS
- Web: Redeploy to Vercel or restart the server
”Missing Supabase environment variables” Error
This error occurs when required variables are not set:Next Steps
Supabase Setup
Configure your Supabase backend and database
Mobile Deployment
Deploy the mobile app to app stores
Web Deployment
Deploy the web dashboard to production