Files
supabase/apps/docs/content/guides/functions/regional-invocation.mdx
Lydia HallieandCharis a26c01217d Update Edge Functions docs (#36798)
* Update Environment Variables docs

* Update Dependencies docs

* Add Function Configuration d ocs

* Add custom Configuration section in Navigation

* Add Error Handling section

* Add new HTTP Methods section

* Update Deno 2 Guide

* Update nav

* Rm deno2 nav

* Update Deploy section

* Update CI/CD section

* Update Logging

* Update Testing

* Update Local Debugging

* Update Troubleshooting

* Update Nav

* Update CLI Quickstart

* Update Dashboard Quickstart

* Update Development Environment

* Update Nav

* Fix links

* Update apps/docs/content/guides/functions/quickstart-dashboard.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/development-environment.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/development-environment.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/quickstart.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Use $CodeSample for multi-root example

* Use tocVideo instead of video embed

* Rm typo

* Switch Quickstart ordering

* Rephrase Docker requirement for deployment

* Add Project Structure section

* style: fix docs lint issues

* Update Regional Invocations

* Update Error Handing

* Fix linting

* Fixes

* Remove duplicate sections

* Update Auth integration

* Update Storage

* Update Database/Postgres

* Update Nav

* Update Background Tasks

* Update Ephemeral Storage

* Update Websockets

* Update Routing

* Update wasm

* Update AI models

* Fix linting issues

* Update apps/docs/content/guides/functions/ai-models.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/ai-models.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/ai-models.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/storage-caching.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/websockets.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/websockets.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/docs/content/guides/functions/ai-models.mdx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Rm unnecessary lines

* Rm wrong example

* Fix typo

* Rm deno2

* Move CICD to deployment and rename routing

* Fix whitespace

* rm unnecessary spelling

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2025-07-10 14:18:01 +00:00

94 lines
2.6 KiB
Plaintext

---
id: 'function-regional-invocation'
title: 'Regional Invocations'
description: 'How to execute an Edge Functions in a particular region.'
subtitle: '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.
<$CodeTabs>
```js name=JavaScript
import { createClient, FunctionRegion } from '@supabase/supabase-js'
const { data, error } = await supabase.functions.invoke('function-name', {
...
region: FunctionRegion.UsEast1, // Execute in us-east-1 region
})
```
```bash name=cURL
curl --request POST 'https://<project_ref>.supabase.co/functions/v1/function-name' \
--header 'x-region: us-east-1' # Execute in us-east-1 region
```
</$CodeTabs>
In case you cannot add the `x-region` header to the request (e.g.: CORS requests, Webhooks), you can use `forceFunctionRegion` query parameter.
<Admonition type="note">
You can verify the execution region by looking at the `x-sb-edge-region` HTTP header in the response. You can also find it as metadata in [Edge Function Logs](/docs/guides/functions/logging).
</Admonition>
---
## 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.
<Admonition type="caution">
Test your function's performance with and without regional specification to determine if the benefits outweigh automatic region selection.
</Admonition>