🗄️ Supabase
Set up your backend database and authentication with Supabase CLI.
📦 Install Supabase CLI
1. Install CLI
# Install Supabase CLI
brew install supabase/tap/supabase
2. Verify Installation
supabase --version
🏠 Local Development Setup
1. Start Docker
Make sure Docker is running on your machine:
# Start Docker Desktop or verify Docker is running
docker --version
2. Start Supabase Locally
# Start local Supabase instance
supabase start
This will start:
- Database (PostgreSQL)
- Auth server
- Edge Functions runtime
- Dashboard at http://localhost:54323
3. Get Local Environment Variables
# Check status and get all URLs/keys
supabase status
Copy the values and add them to your .env.local
file:
# --- Supabase ---
# Your Supabase project URL (e.g., https://xxxxx.supabase.co
# or http://localhost:54321)
EXPO_PUBLIC_SUPABASE_URL=
# Your Supabase anonymous key
EXPO_PUBLIC_SUPABASE_ANON_KEY=your-local-anon-key
# Your Supabase service role key (secret)
SUPABASE_SERVICE_ROLE_KEY=your-local-service-role-key
4. Start Edge Functions (Development)
# Start functions locally
supabase functions serve
🔧 Edge Functions Environment Variables
Local Secrets
Copy the environment template and fill it with your keys:
# Copy the template to create your environment file
cp supabase/functions/.env.template supabase/functions/.env
Then edit supabase/functions/.env
with your API keys:
# supabase/functions/.env
# --- Resend (optional) ---
RESEND_API_KEY=re_your_api_key
RESEND_FROM_EMAIL=noreply@yourapp.com
# --- OpenAI (optional) ---
OPENAI_API_KEY=sk_your_openai_key
# --- Stripe (optional) ---
STRIPE_SECRET_KEY=sk_test_your_stripe_secret
STRIPE_WEBHOOKS_SECRET=whsec_your_webhook_secret
# --- Expo ---
EXPO_ACCESS_TOKEN=your_expo_access_token
# --- Auth providers ---
SUPABASE_AUTH_EXTERNAL_APPLE_SECRET=your_apple_jwt_token
SUBASE_AUTH_GOOGLE_ID=your_google_client_id.apps.googleusercontent.com
💡 Note Importante: Don't worry if you don't have all the keys yet - you can come back later to fill them in as you configure each service.
This file is automatically loaded when you run supabase start
.
☁️ Deploy to Supabase Cloud (Optional)
Prerequisites: Make sure you've completed the local setup above before deploying to cloud.
1. Login to Supabase
# Login to your Supabase account
supabase login
2. Link Your Project
# Link to existing cloud project
supabase link
# Optional: specify database password
supabase link -p your-database-password
3. Push Configuration
# Push your local config to cloud
supabase config push
4. Reset Database
# Reset database with your SQL files
supabase db reset --linked
# If it doesn't work, add the database password:
SUPABASE_DB_PASSWORD=your-db-password supabase db reset --linked
5. Deploy Edge Functions
# Deploy all functions to cloud
supabase functions deploy
6. Update Environment Variables
After deployment, update your .env.local
with cloud values:
# --- Supabase Cloud ---
EXPO_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co
EXPO_PUBLIC_SUPABASE_ANON_KEY=your-cloud-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-cloud-service-role-key
⚡ Deploy Secrets to Cloud
Optional: If you're deploying to cloud, upload your local secrets to Supabase:
# Push your local environment variables to Supabase cloud
supabase secrets set --env-file supabase/functions/.env
🛠️ Common Commands
# Start local development
supabase start
# Check status and get keys
supabase status
# Stop local instance
supabase stop
# Reset local database
supabase db reset
# View logs
supabase logs
🎯 Next Step
Continue to 🔔 Expo Notifications to get push token.
🗄️ Supabase Local Setup Complete ✅
Your local backend is running and ready!