Flutter Community

Supabase Edge Functions in Dart

thumbnail

Supabase Edge Functions in Dart

In this article, we will cover the following topics:

  • Setting up Supabase
  • Creating an Edge Function using Dart
  • Deploying and consuming the endpoint

Setting up Supabase

Supabase is a database service that uses standard PostgreSQL. Before diving into Supabase, we need to install Supabase CLI, a tool to develop your project locally and deploy it to the Supabase Platform.

After starting all the Supabase services, you will receive an output showing your local Supabase credentials which include URLs and keys. You can use these credentials in your local project.

Supabase Edge Functions using Dart

Supabase Edge Functions is a serverless computing platform that allows you to run custom code on the edge. With Supabase Edge Functions, you can build and deploy functions using TypeScript and JavaScript. Additionally, Edge Functions can interact with other Supabase services. We will be using Deno Dart Edge to execute the Dart code on Edge functions.

VideoFetcher Edge Function

We will create two endpoints — fetcher and videoSaver. In the fetcher endpoint, we will simply query our table which is present inside our Postgres database. To fetch data from a PostgreSQL table in a Supabase Edge function, we can use the Supabase Dart client library to query the database.

VideoSaver Edge Function

In the VideoSaver Edge Function, we will access the YouTube APIs and store the response in our table. But before doing that, we need to create a project on Google Cloud and enable the YouTube API. We can then test our function by using the curl command.

Overall, Supabase Edge Functions using Dart is a powerful tool that allows developers to build and deploy functions quickly and easily.