Skip to content

Configuring Regions for Vercel Functions

Learn how to configure regions for Vercel Functions.

In a globally distributed application, the physical distance between your function and its data source can impact latency and response times. Therefore, Vercel allows you to specify the region in which your functions execute, ideally close to your data source (such as your database). This guide will walk you through configuring regions for your Vercel Functions.

For Serverless Functions

  • By default, Serverless Functions execute in Washington, D.C., USA (iad1) for all new projects to ensure they are located close to most external data sources, which are hosted on the East Coast of the USA. You can set a new default region through your project's settings on Vercel
  • You can define the region in your vercel.json using the regions setting
  • You can set your region in the Vercel CLI

For Edge Functions:

  • By default Edge Functions execute in the region closest to the incoming request
  • You can set one or more preferred regions using the route segment config preferredRegions or specify a regions key within a config object to set one or more regions for you functions to execute in
This can only be set for Edge Functions

By default, Edge Functions execute in the region that is geographically closest to the incoming request, reducing network request times. However, if your function depends on a data source, you may want it to be close to that source for fast responses.

To configure which region (or multiple regions) you want your function to execute in, pass the ID of your preferred region(s) in the following way:

The preferredRegion option can be used to specify a single region using a string value, or multiple regions using a string array. See the Next.js documentation for more information.

Next.js (/app)
Next.js (/pages)
Other frameworks
app/api/regional-example/route.ts
export const runtime = 'edge'; // 'nodejs' is the default
export const preferredRegion = 'iad1'; // only execute this function on iad1
export const dynamic = 'force-dynamic'; // no caching
 
export function GET(request: Request) {
  return new Response(`I am an Edge Function!`, {
    status: 200,
  });
}

During regional outage, Vercel has automatic failover to the next closest region to maintain uptime. This is applicable for both global and regionally specified Edge Functions. See the outage resiliency docs for more information.

The default Function region is Washington, D.C., USA (iad1) for all new projects.

To change the default region in the dashboard:

  1. Choose the appropriate project from your dashboard on Vercel
  2. Navigate to the Settings tab
  3. From the left side, select Functions
  4. Use the Function Region dropdown to select your project's default region:

    The Function Region setting in a Vercel project's dashboard

This can only be set for Serverless Functions

To change the default region in your vercel.json configuration file, add your region code to the "regions" key:

vercel.json
{
  "regions": ["sfo1"]
}

Enterprise users can also use functionFailoverRegions to specify regions that a Serverless Function should failover to if the default region is out of service.

This can only be set for Serverless Functions

Use the vercel --regions command in your project's root directory to set a region. Learn more about setting regions with the vercel --regions command in the CLI docs

Multiple Serverless Function regions are only allowed for Enterprise accounts. If your Project requires more than one Serverless Function region, contact Sales.

Multiple Edge Functions regions can be set regardless of your plan.

To learn more about the regions that you can set for your Functions, see the region list.

Both Edge and Serverless Functions can automatically failover to another region:

Setting failover regions are available on Enterprise plans

To ensure the automatic failover to a fallback region in the event of an outage, you can pass one or more regions to the functionFailoverRegions property in your vercel.json file:

vercel.json
{
  "functionFailoverRegions": ["dub1", "fra1"]
}

The region(s) set in the functionFailoverRegions property must be different from the default region(s) specified in the regions property.

During an automatic failover, Vercel will reroute application traffic to the next closest region, meaning the order of the regions in functionFailoverRegions does not matter. For more information on how failover routing works, see functionFailoverRegions.

You can view your default and failover regions through the deployment summary:

Failover regions for your Serverless Functions shown in the deployment summary.
Failover regions for your Serverless Functions shown in the deployment summary.

Region failover is supported with Secure Compute, see Region Failover to learn more.

Vercel provides automatic failover for Edge Functions. In the event of regional downtime, Vercel will reroute application traffic to the next closest Edge Network region. For more information on which regions Vercel routes traffic to, see Outage Resiliency.

Last updated on December 1, 2023