Guides

Develop with Supabase

Initialize and configure Supabase for local development in a mono-repo with Expo, Next.js, and shared components.

Develop with Supabase

This guide covers initialization and usage of Supabase in a mono-repo environment that includes Expo, Next.js, and shared components.

Architecture

For detailed architectural information, refer to the Supabase integration documentation.

Supabase Initialization

The local Supabase setup comes pre-configured with edge functions, Google Auth, email authentication, tables, and storage buckets.

Setup Steps

  1. Start Docker: Ensure Docker is running before beginning setup.

  2. Launch Supabase: Execute the initialization script from the root package.json:

Terminal
npm run supabase:start
  1. Configure Environment Variables: The startup command displays secret keys that should be saved and added to your env files:
Terminal
SUPABASE_URL=http://localhost:54321
SUPABASE_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
SUPABASE_JWT_SECRET=your-jwt-secret

Migrations

The migration setup establishes database tables and implements Row Level Security (RLS) policies. This includes:

  • Tables and storage buckets linked via primary keys
  • RLS policies for tables and storage
  • Event triggers like create_new_user

Edge Functions

Three edge functions are available:

  • payment-data-native: Initializes Stripe payments for native devices
  • payment-data-web: Initializes Stripe payments for web platforms
  • stripe-webhook: Triggered by Stripe events (not called directly by clients)

Edge Function Environment Setup

Environment variables are located at apps/supabase/supabase/functions/stripe-webhook/.env.example and require:

Terminal
BASE_SUPABASE_URL=
SERVICE_ROLE_KEY=
STRIPE_WEBHOOK_SIGNING_SECRET=
STRIPE_SECRET_KEY=
STRIPE_PUBLISHABLE_KEY=

Invocation Methods

Direct Invocation: Use supabase.functions.invoke from client applications:

const { data, error } = await supabase.functions.invoke('hello', {
  body: { foo: 'bar' },
})

Serve as API: Run functions as HTTP endpoints:

Terminal
npx supabase@latest functions serve --no-verify-jwt stripe-webhook --env-file ./supabase/functions/stripe-webhook/.env.development

Or use the built-in script:

Terminal
npm run supabase:webhook-serve
AvatarEnda Kelly

© 2026 Enda Kelly, trading as CloudNua. All rights reserved.

Ireland