Skip to content

Integration: Supabase

Supabase is the backbone — PostgreSQL, Auth, Edge Functions (Deno), and Storage.

Client

A single browser client singleton lives at src/lib/supabaseClient.js. Never create additional clients. Admin-only features use src/lib/customSupabaseClient.js.

How it's used

CapabilityWhereNotes
Authsrc/contexts/SupabaseAuthContext.jsxuseAuth()Session + user. EFs re-verify the JWT server-side.
Reads (RPC)hookssupabase.rpc('get_…'). See Data Access.
Writes (EF)servicessupabase.functions.invoke('…').
Realtimehookssupabase.channel() for frequently-INSERTed tables.
StorageEFs / specific featurese.g. trainer KYC documents.

Two independent projects — Production and Dev/UAT

Since 2026-07-08 (NFX-027), Nefoxx runs two separate Supabase projects, not one shared backend:

ProjectRefServes
Nefoxx-Prodlyaldbfgdhxpllgxbcxpnefoxx.com
Nefoxx-Devrchglrpywmxkcbmxcepldevv.nefoxx.com, uatt.nefoxx.com, local npm run dev

Every migration, Edge Function, secret, storage bucket, and cron job must be promoted to both — full rule, promotion runbook, and current parity status: Environment Strategy.

Local development

  • npx supabase CLI runs a local stack (supabase start) for the E2E/local-Docker workflow — separate from both hosted projects above.
  • The CLI is linked to exactly one hosted project at a time (supabase link --project-ref <ref>); npx supabase db push --linked applies local migrations to whichever project is currently linked — defaults to Nefoxx-Dev day-to-day, must be deliberately relinked to Nefoxx-Prod to promote a change.
  • npm run test:db runs pgTAP tests against the local DB.

Edge functions

67 functions under supabase/functions/, sharing _shared/ utilities, deployed to both projects. See Backend architecture and the EF index.

Hard rules

  • No supabase.from() anywhere in src/.
  • RLS on every user-facing table; the EF is the primary enforcement layer.