How to Use Supabase
LightningAddon supports Supabase as a backend for authentication, database, and server-side flows. This guide walks you through setting it up.
Prerequisites
Step 1: Extension Environment
Add these to envs/.env.development (and envs/.env.production for builds):
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_...
VITE_AUTH_PROVIDER=supabase
Get the Supabase URL and anon key from your project's Settings → API in the Supabase dashboard.
Step 2: Server Environment
Create envs/.env.supabase.local for your Supabase Edge Functions:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
STRIPE_API_KEY=sk_test_...
STRIPE_PRICE_ID_MONTHLY=price_...
STRIPE_PRICE_ID_YEARLY=price_...
STRIPE_WEBHOOK_SIGNING_SECRET=whsec_...
RESEND_API_KEY=re_...
- SUPABASE_SERVICE_ROLE_KEY: From Supabase Settings → API (never expose in the extension)
- STRIPE_*: From Stripe Dashboard
- RESEND_API_KEY: For sending welcome emails (optional)
Step 3: Run Supabase Locally
From the apps/supabase directory (or project root):
supabase functions serve --env-file ../../envs/.env.supabase.local
Or from the project root, adjust the path to your envs/ folder as needed.
Step 4: Deploy Edge Functions
supabase functions deploy
Set the secrets in Supabase Dashboard or via CLI:
supabase secrets set STRIPE_API_KEY=sk_live_...
supabase secrets set STRIPE_WEBHOOK_SIGNING_SECRET=whsec_...
What You Get with Supabase
| Feature | Implementation |
|---|---|
| Auth | Supabase Auth (email/password) |
| Database | Postgres (SQL) |
| Server logic | Edge Functions (Deno) |
| Stripe checkout | stripe-checkout function |
| Stripe portal | stripe-manage-subscription function |
| Stripe webhook | handle-stripe-webhook function |
| Welcome email | Resend (via webhook handler) |
| Session restore | Cookie-based: sb-access-token + sb-refresh-token from chrome.cookies |
Auto-Detection
If you don't set VITE_AUTH_PROVIDER, LightningAddon auto-detects based on which keys are present. If both Supabase and Firebase keys exist, set VITE_AUTH_PROVIDER=supabase explicitly.