Home

Invoke a function

Invokes a function

Invoke a Supabase Function.

  • Requires an Authorization header.
  • Invoke params generally match the Fetch API spec.
  • When you pass in a body to your function, we automatically attach the Content-Type header for Blob, ArrayBuffer, File, FormData and String. If it doesn't match any of these types we assume the payload is json, serialise it and attach the Content-Type header as application/json. You can override this behaviour by passing in a Content-Type header of your own.
  • Responses are automatically parsed as json, blob and form-data depending on the Content-Type header sent by your function. Responses are parsed as text by default.
Parameters
  • functionName
    REQUIRED
    string

    The name of the Function to invoke.

  • options
    Optional
    FunctionInvokeOptions

    Options for invoking the Function.


const { data, error } = await supabase.functions.invoke('hello', {
  body: { foo: 'bar' }
})