Supabase Edge Functions

Supabase Edge Functions

ComeOnOliver Updated 61 repo stars

File contents

Supabase Edge Functions

Create & Deploy

supabase functions new my-function
supabase functions deploy my-function

Function

// supabase/functions/my-function/index.ts
import { serve } from "https://deno.land/std/http/server.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js";

serve(async (req) => {
    const supabase = createClient(Deno.env.get('SUPABASE_URL')!, Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!);
    const { data } = await supabase.from('users').select('*');
    return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } });
});

Invoke: supabase.functions.invoke('my-function', { body: { name: 'test' } })

Secrets: supabase secrets set MY_KEY=value

ComeOnOliver/skillshub/tree/main/skills/skillshub-team/catalog-batch5/supabase-edge-functions commit 8e94979634

Frequently asked questions

npx skillmds@latest add comeonoliver/supabase-edge-functions