Skip to main content

Overview

Supabase Edge Functions are server-side TypeScript functions that run on Deno, distributed globally at the edge. They’re perfect for running custom business logic, integrations with third-party services, or any server-side code.

Base URL

Edge Functions are available at:

Invoking Functions

Basic Invocation

Invoke a function with a POST request.
string
required
The name of the function to invoke (in the URL path).
string
required
Your Supabase API key.
string
Bearer token for authenticated requests (optional for public functions).
string
Set to application/json for JSON payloads.

Response

GET Request

Invoke a function with a GET request.

Custom Headers

Pass custom headers to your function.

Function Examples

Basic Function

A simple Edge Function that returns a greeting.

Database Access

Access your Supabase database from an Edge Function.

OpenAI Integration

Integrate with third-party APIs like OpenAI.

Webhook Handler

Handle webhooks from third-party services.

Environment Variables

Access environment variables in your functions.

Built-in Environment Variables

string
Your Supabase project URL.
string
Your Supabase anon key.
string
Your Supabase service role key (use with caution).
string
Direct connection string to your Postgres database.

Request and Response

Request Object

Access request properties.

Response Object

Return different types of responses.

CORS

Handle CORS for browser requests.

CORS Headers

Authentication

Verify JWT

Verify the user’s JWT token.

Deployment

Deploy via CLI

Deploy via GitHub Actions

Limits and Pricing

Free Tier

  • 500,000 invocations per month
  • 1GB bandwidth per month
  • 100 concurrent executions

Pro Tier

  • 2,000,000 invocations per month
  • 5GB bandwidth per month
  • 500 concurrent executions

Execution Limits

  • Timeout: 60 seconds per invocation
  • Memory: 150MB RAM
  • CPU: Limited based on plan
  • Cold start: ~1-3 seconds

Best Practices

Each function should do one thing well. Create multiple functions for different use cases.
Never hardcode API keys or secrets in your functions:
Always handle errors gracefully:
TypeScript provides better developer experience and catches errors early.
Use appropriate cache headers to reduce function invocations:

Monitoring

View function logs and metrics in the Supabase Dashboard:
  • Logs: Real-time function execution logs
  • Metrics: Invocation count, error rate, execution time
  • Traces: Request/response details

Next Steps

Deploy Your First Function

Learn how to create and deploy Edge Functions

Client Libraries

Invoke functions from your app