> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rocket.new/llms.txt
> Use this file to discover all available pages before exploring further.

# Edge functions

> Connect Supabase Edge Functions to your Rocket.new app - generate and deploy serverless backend logic from chat.

export const LlmsDirective = () => <blockquote className="llms-directive">
    For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
    For a lightweight markdown version of this page, append .md to the URL.
  </blockquote>;

<LlmsDirective />

<Info>
  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.
</Info>

## 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.

<Info>
  <b>Why use Edge Functions with Rocket?</b>
  Rocket writes the function code, prompts you for secrets, and deploys to Supabase. All from chat.
</Info>

## 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`.

<Frame caption="Resend secret prompt during Edge Function creation">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/supabase-resend-API-light.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=9826f3e2d4b393cafff5b3373248c9b1" alt="Popup showing secure input field for Resend API key during function creation." className="theme-image light-image" width="904" height="462" data-path="images/build-docs/connectors/supabase/edge-functions/supabase-resend-API-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/supabase-resend-API-dark.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=11b4ce59f16a2cfeb9c432f82c00c8f6" alt="Popup showing secure input field for Resend API key during function creation." className="theme-image dark-image" width="904" height="462" data-path="images/build-docs/connectors/supabase/edge-functions/supabase-resend-API-dark.webp" />
</Frame>

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

<Frame caption="Deploy Edge Function from Rocket">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/edge-function-popup-light.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=faf6db05cc1b326fada48e0646ac9894" alt="Edge Function deployment popup with code preview, secret fields, and deploy button." className="theme-image light-image" width="904" height="818" data-path="images/build-docs/connectors/supabase/edge-functions/edge-function-popup-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/edge-function-popup-dark.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=4e30426f7d8997155bd444017ece98fe" alt="Edge Function deployment popup with code preview, secret fields, and deploy button." className="theme-image dark-image" width="904" height="818" data-path="images/build-docs/connectors/supabase/edge-functions/edge-function-popup-dark.webp" />
</Frame>

<Note>
  No need to open the Supabase dashboard unless you want to review or manage functions manually.
</Note>

## View functions and secrets in Supabase

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

**View deployed functions:**

<Frame caption="Supabase: list of deployed Edge Functions">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/supabase-edge-function-light.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=2b84138246f5ba7ccad2cf24235def01" alt="Supabase dashboard showing a list of deployed Edge Functions." className="theme-image light-image" width="2880" height="1624" data-path="images/build-docs/connectors/supabase/edge-functions/supabase-edge-function-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/supabase-edge-function-dark.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=f9114a1cbeeb6f66917fc312bdb10a21" alt="Supabase dashboard showing a list of deployed Edge Functions." className="theme-image dark-image" width="2880" height="1624" data-path="images/build-docs/connectors/supabase/edge-functions/supabase-edge-function-dark.webp" />
</Frame>

<Frame caption="Supabase: deployed Edge Function details">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/kK5WOZR2-IAgA9O3/images/build-docs/connectors/supabase/edge-functions/edge-function-supabase-light.webp?fit=max&auto=format&n=kK5WOZR2-IAgA9O3&q=85&s=4cd47cbf9db1ecf4e4ebe0fccf035d35" alt="Supabase dashboard showing Edge Function details and status." className="theme-image light-image" width="940" height="744" data-path="images/build-docs/connectors/supabase/edge-functions/edge-function-supabase-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/kK5WOZR2-IAgA9O3/images/build-docs/connectors/supabase/edge-functions/edge-function-supabase-dark.webp?fit=max&auto=format&n=kK5WOZR2-IAgA9O3&q=85&s=96895219e0d6833abedd473b1556ce56" alt="Supabase dashboard showing Edge Function details and status." className="theme-image dark-image" width="940" height="744" data-path="images/build-docs/connectors/supabase/edge-functions/edge-function-supabase-dark.webp" />
</Frame>

**View stored secrets:**

<Frame caption="Supabase: stored secrets for Edge Functions">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/supabase-secrets-function-light.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=197b01cac5c7b433f1a9ea9b63e85cbf" alt="Supabase dashboard displaying secrets linked to Edge Functions." className="theme-image light-image" width="2000" height="1127" data-path="images/build-docs/connectors/supabase/edge-functions/supabase-secrets-function-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/2lqYWidv_xVHKfL6/images/build-docs/connectors/supabase/edge-functions/supabase-secrets-function-dark.webp?fit=max&auto=format&n=2lqYWidv_xVHKfL6&q=85&s=dca6626cc6ef6adb4a44ea075c224fca" alt="Supabase dashboard displaying secrets linked to Edge Functions." className="theme-image dark-image" width="2000" height="1127" data-path="images/build-docs/connectors/supabase/edge-functions/supabase-secrets-function-dark.webp" />
</Frame>

## 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

<Info>
  <b>What you will see:</b>
  Rocket or your app reports that the function does not exist.
</Info>

To fix this:

<Steps>
  <Step title="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.
  </Step>

  <Step title="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.
  </Step>
</Steps>

### 2. Push to Supabase failed

<Info>
  <b>What you will see:</b>
  An error appears when you click **Push to Supabase**.
</Info>

To fix this:

<Steps>
  <Step title="Review the error message">
    Check the error message shown in the popup.
  </Step>

  <Step title="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.
  </Step>

  <Step title="Push the updated function">
    Push the updated function or script as prompted.
  </Step>
</Steps>

<Card icon="server" horizontal title="Backend logic, deployed in minutes">
  Your Rocket app now runs secure server logic with Supabase Edge Functions, all created and deployed from chat.
</Card>

***

## What's next?

<CardGroup cols={2}>
  <Card title="Storage buckets" icon="folder" href="/build/connectors/supabase/storage-buckets">
    Set up file uploads and media storage with Supabase Storage.
  </Card>

  <Card title="Supabase overview" icon="database" href="/build/connectors/supabase/overview">
    See all Supabase features available in Rocket.
  </Card>
</CardGroup>
