Skip to main content

Supabase Integration

Supabase is an open-source Firebase alternative.

Learn how to connect to your Supabase project from Windmill Scripts, Flows and Apps.

Integrattion between Supabase and Windmill

info

This tutorial assumes that you already have a Windmill account and a Supabase project. If you don't, visit the Windmill documentation or the Supabase documentation to find out more.

Through Postgres Protocol

You can execute queries on Supabase through the regular Postgres protocol.

  1. Sign-up to Supabase's Cloud App or Self-Host it.

  2. Create a new Supabase project.

  3. From Windmill, on the Resources menu click on "Add a resource". Pick "postgresql" and "Add a Supabase DB". This will lead you to a Supabase page where you need to pick your organization. Then on Windmill pick a database, fill with database password and that's it.

Through Supabase API

Get the API keys

In order to make authenticated requests to the database, you'll need your API key and the URL of your endpoint from Supabase. To get these, select your project, navigate to the Project Settings page and select API from the menu. You'll find the URL and 2 keys here.

API settings

As the description says, the access level of the public key will be controlled by the policies you add and the secret key will bypass all of them. You can safely use the service_rolesecret secret key in Windmill because it'll never be sent to users directly.

Create a resource

To safely use secret values throughout Windmill, you can save them in reources. We are regularly updating the list of approved resources but if you want an integration to be supported by Windmill directly, please submit a new resource type on Windmill Hub.

Navigate to the Resources page page Resources page

Click "Add a resource/API" Resource selector

Search for Supabase and select the resource type Resource selector

Enter the API key and the URL from Supabase and click "Save" Resource selector

Use the resource

You can reference the type of a Supabase resource in a script the following way:

// To get the latest supported resource types,
// check for the latest version of the Windmill Deno
// package at https://deno.land/x/windmill/mod.ts
type Supabase = {
url: string;
key: string;
};

export async function main(auth: Supabase) {
// Function contents
}