Edge Functions

Regional Invocations

Execute Edge Functions in specific regions for optimal performance.


Edge Functions automatically execute in the region closest to the user making the request. This reduces network latency and provides faster responses.

However, if your function performs intensive database or storage operations, executing in the same region as your database often provides better performance:

  • Bulk database operations: Adding or editing many records
  • File uploads: Processing large files or multiple uploads
  • Complex queries: Operations requiring multiple database round trips

Available regions#

The following regions are supported:

Asia Pacific:

  • ap-northeast-1 (Tokyo)
  • ap-northeast-2 (Seoul)
  • ap-south-1 (Mumbai)
  • ap-southeast-1 (Singapore)
  • ap-southeast-2 (Sydney)

North America:

  • ca-central-1 (Canada Central)
  • us-east-1 (N. Virginia)
  • us-west-1 (N. California)
  • us-west-2 (Oregon)

Europe:

  • eu-central-1 (Frankfurt)
  • eu-west-1 (Ireland)
  • eu-west-2 (London)
  • eu-west-3 (Paris)

South America:

  • sa-east-1 (São Paulo)

Usage#

You can specify the region programmatically using the Supabase Client library, or using the x-region HTTP header.

1
import { createClient, FunctionRegion } from '@supabase/supabase-js'
2
3
const { data, error } = await supabase.functions.invoke('function-name', {
4
...
5
region: FunctionRegion.UsEast1, // Execute in us-east-1 region
6
})

In case you cannot add the x-region header to the request (e.g.: CORS requests, Webhooks), you can use forceFunctionRegion query parameter.


Region runtime information#

Functions have access to the following environment variables:

SB_REGION: The AWS region function was invoked

This is useful if you have read replicate and want to Postgres connect to a different replicate according of the Region.


Region outages#

When you explicitly specify a region via the x-region header, requests will NOT be automatically re-routed to another region.

During outages, consider temporarily changing to a different region.