INTEGRATE

Supabase Edge Functions

You can use Phase to sync secrets to your Supabase project. The secrets are available to your Edge Functions at runtime.

Prerequisites

Step 1: Authentication

Create a Supabase access token

  1. Log in to your Supabase Dashboard. Click your avatar in the top right, then select Account.
Supabase account menu
  1. Go to the Access Tokens tab and click Generate New Token. Enter a descriptive name, select an expiry, and click Generate token. Copy the token. Supabase shows it only once.
Generate new token

Store authentication credentials in Phase

  1. Go to Integrations in the sidebar. Then click Third-party credentials in the integrations tab.
Go to integrations
  1. Click Supabase.
supabase-create-creds
  1. Enter your Supabase Access Token from the previous step. Enter a descriptive name and click Save.
supabase-input-creds

Phase encrypts and saves your credentials. You can view and manage them under Service Credentials in the Integrations screen.

Step 2: Set up a secret sync

  1. Open your App in the Phase Console and go to the Syncing tab. Select Supabase Edge Functions in the 'Create a new Sync' menu.
create supabase sync
  1. Select the credentials that you added in the previous step. Then click Next.
select supabase creds
  1. Configure the source and destination for your secrets. Select an Environment from your App as the source. If you want to sync from a specific folder, set the Path. Then select a Supabase project from the dropdown and click Create.
configure supabase sync
  1. Phase now syncs your secrets to the selected Supabase project automatically. You can manage the sync from the Syncing tab of your App or from the Integrations screen.
supabase sync card

Synced secrets are available to your Edge Functions without a redeploy. To see them, open the Edge Functions → Secrets page in the Supabase Dashboard, or use the Supabase CLI:

supabase secrets list --project-ref <your-project-ref>

An Edge Function reads the synced secrets as environment variables:

Deno.serve(async () => {
  const stripeKey = Deno.env.get('STRIPE_SECRET_KEY')

  return new Response(
    JSON.stringify({ stripeKeyIsSet: Boolean(stripeKey) }),
    { headers: { 'Content-Type': 'application/json' } },
  )
})