> ## Documentation Index
> Fetch the complete documentation index at: https://dhiwisepvtltd-5e04e6a4.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Edge functions

> Generate and deploy Supabase Edge Functions from Rocket.new chat to add serverless backend logic, webhooks, and secure API endpoints to your app.

> [!NOTE]
>
> Rocket auto-detects when backend logic is needed and generates Supabase Edge Functions for you. This guide covers creating and deploying functions from chat, adding secrets securely, and troubleshooting deployment errors.

## What are Supabase Edge Functions?

Edge Functions run on Supabase infrastructure and handle secure backend logic for your app.
They are ideal for tasks like sending emails, calling APIs, generating PDFs, or processing data.

* Execute on the server, not the user's device.
* Can store and use secrets securely.
* Can be triggered from your UI or backend processes.

> [!NOTE]
>
> **Why use Edge Functions with Rocket?**
> Rocket writes the function code, prompts you for secrets, and deploys to Supabase. All from chat.

## Create or detect a function in Rocket

Rocket auto-checks if backend logic is needed when you build features.
If a function is required and does not exist, Rocket generates it and opens a chat popup.

You will see:

* The function name and a code preview.
* Input fields for any required secrets.
* A **Push to Supabase** button to deploy.

You can also ask Rocket to create a function manually. For example:

```plaintext wrap theme={null}
Create an Edge Function that sends a welcome email with Resend when a user signs up.
```

Rocket will:

* Write the function code.
* Prompt for the `RESEND_API_KEY`.

![Popup showing secure input field for Resend API key during function creation.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/supabase-resend-API-light.webp)

![Popup showing secure input field for Resend API key during function creation.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/supabase-resend-API-dark.webp)

Resend secret prompt during Edge Function creation

* Show a **Push to Supabase** popup so you can deploy the function.

![Edge Function deployment popup with code preview, secret fields, and deploy button.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/edge-function-popup-light.webp)

![Edge Function deployment popup with code preview, secret fields, and deploy button.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/edge-function-popup-dark.webp)

Deploy Edge Function from Rocket

> [!NOTE]
>
> No need to open the Supabase dashboard unless you want to review or manage functions manually.

## View functions and secrets in Supabase

To review deployed functions or confirm stored secrets, use the Supabase dashboard.

**View deployed functions:**

![Supabase dashboard showing a list of deployed Edge Functions.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/supabase-edge-function-light.webp)

![Supabase dashboard showing a list of deployed Edge Functions.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/supabase-edge-function-dark.webp)

Supabase: list of deployed Edge Functions

![Supabase dashboard showing Edge Function details and status.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/edge-function-supabase-light.webp)

![Supabase dashboard showing Edge Function details and status.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/edge-function-supabase-dark.webp)

Supabase: deployed Edge Function details

**View stored secrets:**

![Supabase dashboard displaying secrets linked to Edge Functions.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/supabase-secrets-function-light.webp)

![Supabase dashboard displaying secrets linked to Edge Functions.](https://mintlify.s3.us-west-1.amazonaws.com/dhiwisepvtltd-5e04e6a4/images/build/connectors/supabase/edge-functions/supabase-secrets-function-dark.webp)

Supabase: stored secrets for Edge Functions

## Add secrets securely

When Rocket asks for secrets:

* Paste them into the secure input fields provided.
* The secrets are saved in Supabase, not Rocket.
* You can update or rotate them later by asking Rocket to redeploy.

## Call your function from the app

Once deployed, Rocket can automatically wire your function into your app.
You can also ask for specific triggers, such as:

* After user actions like signups or button clicks.
* From other backend processes.

To test first, ask Rocket to add a test button that triggers the function safely during development.

## Example: Send a welcome email

**Prompt:**

```plaintext wrap theme={null}
Send a welcome email using Resend when a new user signs up.
```

**Rocket will:**

* Generate the function.
* Request the `RESEND_API_KEY`.
* Show a **Push to Supabase** popup.
* Connect the function to your signup flow.

## Troubleshooting

### 1. Function not found

> [!NOTE]
>
> **What you will see:**
> Rocket or your app reports that the function does not exist.

To fix this:

**1. Click Fix it**

Rocket shows an error popup with a **Fix it** button. Click it. Rocket will check the issue and either:

* Repair the function and show a **Push to Supabase** popup.
* Generate a script to deploy if schema changes are needed.

**2. Describe unexpected behavior**

If the function exists but does not behave as expected, describe the problem clearly in chat. For example:

```plaintext wrap theme={null}
When users sign up, they are not receiving the welcome email.
```

Rocket will inspect, apply changes, and prompt you to redeploy.

### 2. Push to Supabase failed

> [!NOTE]
>
> **What you will see:**
> An error appears when you click **Push to Supabase**.

To fix this:

**1. Review the error message**

Check the error message shown in the popup.

**2. Click Fix it**

If a **Fix it** button is available, click it. Rocket will:

* Fix the function.
* Show a new **Push to Supabase** popup so you can retry.

**3. Push the updated function**

Push the updated function or script as prompted.

> **Backend logic, deployed in minutes**
>
> Your Rocket app now runs secure server logic with Supabase Edge Functions, all created and deployed from chat.

***

## What's next?

> **[Storage buckets](https://dhiwisepvtltd-5e04e6a4.mintlify.site/build/connectors/supabase/storage-buckets.md)**
>
> Set up file uploads and media storage with Supabase Storage.

> **[Supabase overview](https://dhiwisepvtltd-5e04e6a4.mintlify.site/build/connectors/supabase/overview.md)**
>
> See all Supabase features available in Rocket.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.