Skip to main content

Deployment Methods

Supabase Edge Functions can be deployed using:
  • Supabase CLI: Manual deployments from your local machine
  • GitHub Actions: Automated CI/CD deployments
  • Other CI/CD: GitLab CI, CircleCI, Bitbucket Pipelines, etc.

CLI Deployment

Deploy a Single Function

Deploy one function:
Output:

Deploy All Functions

Deploy all functions in your project:
Since Supabase CLI v1.62.0, you can deploy all functions with a single command.

Deploy to a Specific Project

Deploy to a specific project using the project reference:
Or link your project first:

Verify Deployment

List all deployed functions:
Output:

GitHub Actions Deployment

Automate deployments when you push code to GitHub.

Setup

1. Generate Access Token

  1. Go to https://supabase.com/dashboard/account/tokens
  2. Click “Generate New Token”
  3. Give it a name like “GitHub Actions”
  4. Copy the token

2. Add Token to GitHub Secrets

  1. Go to your GitHub repository
  2. Navigate to Settings > Secrets and variables > Actions
  3. Click “New repository secret”
  4. Name: SUPABASE_ACCESS_TOKEN
  5. Value: Paste your token
  6. Click “Add secret”

3. Create Workflow File

Create .github/workflows/deploy.yml:

Deploy Specific Functions

Deploy only specific functions:

Deploy on Path Changes

Only deploy when function code changes:

Deploy with Secrets

Set secrets during deployment:

Multi-Environment Deployment

Deploy to staging and production:

Configuration

Function Configuration

Configure individual functions in config.toml:

Configuration Options

verify_jwt

Control JWT verification:
Only disable JWT verification for public webhooks or functions that implement their own authentication.

import_map

Specify custom import map location:

Import Maps

Import maps let you alias module URLs for easier imports.

Create Import Map

Create supabase/functions/import_map.json:

Use Aliases

Now use short aliases in your functions:

Function-Specific Import Maps

Create per-function import maps:

Advanced Deployment Strategies

Blue-Green Deployment

Deploy new version alongside old version:

Canary Deployment

Gradually roll out new version:
  1. Deploy new version
  2. Route small percentage of traffic to new version
  3. Monitor metrics and errors
  4. Gradually increase traffic
  5. Complete rollout or rollback if issues found
Canary deployments require a load balancer or custom routing logic in your application.

Rolling Back

Quickly revert to previous version:

Deployment Best Practices

Version Control

Always commit function code to git:

Test Before Deploy

Run tests locally before deploying:

Deployment Checklist

Before deploying:
  • Test function locally
  • Set required environment variables
  • Update function configuration in config.toml
  • Review code changes
  • Check for breaking changes
  • Verify JWT settings
  • Test with production-like data

Monitor Deployments

Check logs after deployment:
Monitor for:
  • Increased error rates
  • Performance degradation
  • Unexpected behavior

CI/CD with Other Platforms

GitLab CI

Create .gitlab-ci.yml:

CircleCI

Create .circleci/config.yml:

Bitbucket Pipelines

Create bitbucket-pipelines.yml:

Troubleshooting

Deployment Fails

If deployment fails:
  1. Check CLI version:
  2. Verify project link:
  3. Check access token:
  4. Review function code for syntax errors

Function Not Updating

If changes don’t appear:
  1. Verify deployment succeeded:
  2. Check function version increased
  3. Clear browser cache if testing in browser
  4. Wait a few seconds for propagation

Permission Errors

If you get permission errors:
  1. Regenerate access token with correct permissions
  2. Update token in secrets for CI/CD
  3. Verify project reference is correct

Next Steps

Environment Variables

Manage secrets and configuration

Debugging

Debug and monitor your functions

Resources