Skip to content

Use cases

There are many use cases where you might want to create a Postgres function in Supabase and call it in WeWeb.

Common use cases include but are not limited to:

  • sending an email,
  • formatting data in the backend before sending it back to WeWeb,
  • doing resource-intensive calculations a browser can't handle efficiently,
  • making an API call through your backend.

TIP

API calls that use a secret key should always be made through your backend.

Learn more about the difference between public and private API keys.

Postgres function example

Create a function in Supabase

In the example below, we followed Supabase's instructions to create a function that:

  1. accepts a name input,
  2. gets a Kanye West quote from an API, and
  3. returns a text that says: "Hey {name}, {kanye_quote}".

Call a Supabase function in WeWeb

In WeWeb, all we have to do is:

  1. call the Supabase function, in our case talk_to_kanye
  2. add my name input and bind it to the current user's nickname
  3. test my workflow to check that the return value matches what I expected

Supabase Postgres function example

And that's it!

That's how you can call a Supabase Postgres function via your WeWeb app.