Edge Functions

Deploy to Production

Deploy your Edge Functions to your remote Supabase Project.


Once you have developed your Edge Functions locally, you can deploy them to your Supabase project.


Step 1: Authenticate

Log in to the Supabase CLI if you haven't already:

1
supabase login

Step 2: Connect your project

Get the project ID associated with your function:

1
supabase projects list

Link your local project to your remote Supabase project using the ID you just retrieved:

1
supabase link --project-ref your-project-id

Now you should have your local development environment connected to your production project.


Step 3: Deploy Functions

You can deploy all edge functions within the functions folder with a single command:

1
supabase functions deploy

Or deploy individual Edge Functions by specifying the function name:

1
supabase functions deploy hello-world

Deploying public functions

By default, Edge Functions require a valid JWT in the authorization header. If you want to deploy Edge Functions without Authorization checks (commonly used for Stripe webhooks), you can pass the --no-verify-jwt flag:

1
supabase functions deploy hello-world --no-verify-jwt

Step 4: Verify successful deployment

🎉 Your function is now live!

When the deployment is successful, your function is automatically distributed to edge locations worldwide. Your edge functions is now running globally at http://[YOUR_PROJECT_ID].supabase.co/functions/v1/hello-world.


Step 5: Test your live function

You can now invoke your Edge Function using the project's ANON_KEY, which can be found in the API settings of the Supabase Dashboard. You can invoke it from within your app:

1
2
3
4
curl --request POST 'http://<project_id>.supabase.co/functions/v1/hello-world' \ --header 'Authorization: Bearer ANON_KEY' \ --header 'Content-Type: application/json' \ --data '{ "name":"Functions" }'

You should now see the expected response:

1
{ "message": "Hello Production!" }

CI/CD deployment

You can use popular CI / CD tools like GitHub Actions, Bitbucket, and GitLab CI to automate Edge Function deployments.

GitHub Actions

You can use the official setup-cli GitHub Action to run Supabase CLI commands in your GitHub Actions.

The following GitHub Action deploys all Edge Functions any time code is merged into the main branch:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
name: Deploy Functionon: push: branches: - main workflow_dispatch:jobs: deploy: runs-on: ubuntu-latest env: SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }} PROJECT_ID: your-project-id steps: - uses: actions/checkout@v4 - uses: supabase/setup-cli@v1 with: version: latest - run: supabase functions deploy --project-ref $PROJECT_ID

GitLab CI

Here is the sample pipeline configuration to deploy via GitLab CI.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
image: node:20# List of stages for jobs, and their order of executionstages: - setup - deploy# This job runs in the setup stage, which runs first.setup-npm: stage: setup script: - npm i supabase cache: paths: - node_modules/ artifacts: paths: - node_modules/# This job runs in the deploy stage, which only starts when the job in the build stage completes successfully.deploy-function: stage: deploy script: - npx supabase init - npx supabase functions deploy --debug services: - docker:dind variables: DOCKER_HOST: tcp://docker:2375

Bitbucket Pipelines

Here is the sample pipeline configuration to deploy via Bitbucket.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
image: node:20pipelines: default: - step: name: Setup caches: - node script: - npm i supabase - parallel: - step: name: Functions Deploy script: - npx supabase init - npx supabase functions deploy --debug services: - docker

Function configuration

Individual function configuration like JWT verification and import map location can be set via the config.toml file.

1
2
[functions.hello-world]verify_jwt = false

This ensures your function configurations are consistent across all environments and deployments.


Example

This example shows a GitHub Actions workflow that deploys all Edge Functions when code is merged into the main branch.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
name: Deploy Functionon: push: branches: - main workflow_dispatch:jobs: deploy: runs-on: ubuntu-latest env: SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }} SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} steps: - uses: actions/checkout@v3 - uses: supabase/setup-cli@v1 with: version: latest - run: supabase functions deploy --project-ref $SUPABASE_PROJECT_ID
View source