mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
Supabase Edge Function Examples
What are Supabase Edge Functions?
Supabase Edge Functions are written in TypeScript, run via Deno, and deployed with the Supabase CLI. Please download the latest version of the Supabase CLI, or upgrade it if you have it already installed.
Example Functions
The function examples are located in ./supabase/functions:
browser-with-cors: Handle CORS headers for function invocations from browser environments.select-from-table-with-auth-rls: Retrieve data from an authenticated user via RLS.
Develop locally
- Run
supabase start(make sure your Docker daemon is running.) - Run
supabase functions serve your-function-name - Run the CURL command in the example function, or use the invoke method on the Supabase client.
Deploy
- Generate access token and log in to CLI
- Navigate to https://app.supabase.io/account/tokens
- Click "Generate New Token"
- Copy newly created token
- Run
supabase login - Input your token when prompted
- Link your project
- Within your project root run
supabase link --project-ref your-project-ref
- Within your project root run
- Set up your secrets
- Run
supabase secrets set --from-stdin < .envto set the env vars from your.envfile. - You can run
supabase secrets listto check that it worked and also to see what other env vars are set by default.
- Run
- Deploy the function
- Within your project root run
supabase functions deploy payment-sheet
- Within your project root run
- In youre
./app/.envfile remove theSUPA_FUNCTION_LOCALHOSTvariable and restart your Expo app.
👁⚡️👁
\o/ That's it, you can now invoke your Supabase Function via the supabase-js and supabase-dart client libraries. (More client libraries coming soon. Check the supabase-community org for details).
For more info on Supabase Functions, check out the docs and the examples.