Skip to content

Function call

This component represents a function call to a Supabase function.

Props

PropTypeDescription
functionNamestringThe name of the Supabase function to call.
headersanyOptional headers to include in the function call.
bodyanyOptional body to include in the function call.

Slots

  • default: This slot is rendered when the function call is successful. It has the following scope variables:
VariableTypeDescription
payloadany| nullThe response payload from the function call.
errorError| nullAny error that occurred during the function call.
functionsFunctionsClientThe Supabase functions client.
  • loading: This slot is rendered while the function call is in progress.

Usage

<script lang="ts">
import { FunctionCall } from 'supasveltekit';
</script>
<FunctionCall functionName="get-time" let:payload let:error>
<div data-testid="function-call">
{#if payload}
<h1>The time is {payload.time}</h1>
{:else if error}
<h1>There was an error: {JSON.stringify(error)}</h1>
{:else}
<h1>Loading...</h1>
{/if}
</div>
</FunctionCall>