Supabase Functions

Supabase Edge Functions are runnable functions distributed globally at the edge. They can be used for listening to webhooks or integrating your Supabase project with third-parties.

Supabase Edge Functions are developed using Deno.

Getting Started#

Before getting started, you need to install the supabase CLI - available via NPM, Homebrew & Scoop.

Once installed, start the Supabase services:

supabase start

Next, either use the edge CLI command or setup manually:

Open the lib/main.dart file to view the minimal HTTP request fetch handler:

void main() {
  SupabaseFunctions(fetch: (request) {
    return Response("Hello from Supabase Edge Functions!");
  });
}

Each incoming request to your edge function will be passed to the fetch handler, which is expected to return a Response instance. The fetch handler provides a Request instance which contains useful information about the incoming request, such as the method, URL, headers, body and more.

Local development#

To run your application locally, first run edge build supabase_functions --dev command from the root of your project:

edge build supabase_functions --dev

This command will start a build watcher which will recompile any changes you make to your project.

Next run the dart_edge function:

supabase functions serve dart_edge --no-verify-jwt

Note: By default Supabase Functions expects a valid auth header. The --no-verify-jwt enables you to run the function without a valid auth header.

You should now be able to access your function at http://localhost:54321/functions/v1/dart_edge.

To learn more about local Supabase development, view their documentation.

Deployment#

To deploy your application to Supabase, run the following commands:

edge build supabase_functions
supabase functions deploy dart_edge