1

Login to Supabase

In order for our Edge Functions to work we need to connect them to our existing Supabase account. Login to Supabase via the CLI:

npx supabase login
2

Pushing The Edge Functions

For our Edge Functions to be available in production we need push them to Supabase:

npm run functions:deploy
3

Enabling Supabase Cron Jobs

Cron Jobs are a custom Supabase extension that needs to be enabled. Here’s how to enable the cron jobs extension:

4

Scheduling The Edge Functions at 00:00

For our last step, we need to schedule our cron jobs to trigger our manage-subscriptions and manage-free-trials edge functions EVERY night at 00:00:00. Here’s how:

Creating a Supabase Edge Function

If needed, it’s also possible to add a new Edge Function using the following command:

npx supabase functions new [function-name]

Testing a Function on Localhost

Pre-Requisites: In order to test Supabase Edge Functions on localhost, please ensure to have Docker Desktop installed. You can download it from [here].

You can start a Supabase Edge Function with the following command:

npx supabase functions serve [function-name]

or run the following command to run all functions:

npm run functions:listen

In order to test the function, please call the following endpoint using Postman with the appropriate HTTP method such as GET, POST, etc. You should now see the console.logs right in the terminal (if present in the function).

http://localhost:54321/functions/v1/[function-name]