Skip to content
For the complete Netlify documentation index, see llms.txt. Markdown versions of this page are available by appending .md to the URL.

Unlimited seats on Netlify Pro for $20/month → Learn more 👥

Configuration for functions

For the complete documentation index, see llms.txt

This page documents the settings you can customize to control how your functions are built, deployed, and executed, along with the default values that apply when you leave a setting unspecified.

Select your function language:

Default values

Unless customized, every function deploys with:

SettingDefaultConfigurable?
Regioncmh (US East, Ohio) 1Yes — Region
Memory1024 MBYes — Memory or vCPU
Synchronous execution limit60 secondsNo
Scheduled execution limit30 secondsNo
Background execution limit15 minutesNo
Buffered request/response payload6 MB 2No
Streamed response payload20 MBNo
Background request/response payload256 KBNo

  1. Sites created before October 4, 2023 may have a different default region. Check your current configuration in Project configuration Build & deploy Continuous deployment Functions region.
  2. Requests with binary payloads such as image uploads are Base64-encoded, which adds approximately 30% overhead — effectively reducing the binary request payload size limit to 4.5 MB.

Beyond these defaults, additional capabilities like Private Connectivity can be enabled by contacting your account manager.

By default, every function is available at https://<YOUR DOMAIN>/.netlify/functions/<FUNCTION NAME>. Use the path property in the function’s config to route it to one or more custom URLs.

import type { Config, Context } from "@netlify/functions"
export default async (req: Request, context: Context) => {
const { city, country } = context.params
return new Response(`You're visiting ${city} in ${country}!`)
}
export const config: Config = {
path: "/travel-guide/:city/:country",
}

When you set a custom path, the function is only available at that path — not at the default /.netlify/functions/<name> URL.

To configure multiple paths, set path as an array.

export const config: Config = {
path: ["/cats", "/dogs"],
}

path supports the web platform URLPattern syntax for wildcards and named groups. Named groups are exposed to the function on context.params.

export const config: Config = {
path: ["/sale/*", "/item/:sku"],
}

Use excludedPath to carve exceptions out of a path pattern. Accepts a single string or an array of strings, each starting with /.

export const config: Config = {
excludedPath: ["/product/*.css", "/product/*.js"],
path: "/product/*",
}

By default, a function runs for any request to its configured paths regardless of whether static files exist there. To let static assets on the CDN win when they exist, set preferStatic: true.

export const config: Config = {
path: ["/product/:sku", "/item/:sku"],
preferStatic: true,
}

By default, a function responds to every HTTP method. Use the method property to restrict it to specific methods.

export const config: Config = {
method: ["GET", "POST"],
path: "/items",
}

This feature is available on all Pro and Enterprise plans.

Netlify offers several regions for deploying your serverless functions. You may want to customize the region for the following reasons:

  • Optimize performance. Deploying serverless functions close to their data sources, such as a database or another backend service, can greatly reduce roundtrip time for data retrieval resulting in faster response times for your users.
  • Ensure compliance. In some cases, data protection laws and industry-specific regulations may require that sensitive data processing happens within specific regions.
  • Use Private Connectivity. Static IP addresses for Private Connectivity are available in only some regions.

Regions are identified by airport code. By default, Netlify deploys functions for new sites to cmh (Ohio) — a common choice for many database providers, which optimizes performance for most cases.

You can change the region through the Netlify UI to any of the following:

Airport codeRegion
cmhUS East (Ohio)
dubEU (Ireland)
fraEU (Frankfurt)
gruSouth America (São Paulo)
iadUS East (N. Virginia)
lhrEU (London)
nrtAsia Pacific (Tokyo)
pdxUS West (Oregon)
sfoUS West (N. California)
sinAsia Pacific (Singapore)
sydAsia Pacific (Sydney)
yulCanada (Central)

In addition to the above self-serve regions, the following are available through support-assisted configuration:

Airport codeRegion
cdgEU (Paris)
mxpEU (Milan)

If you want your site to use one of the above regions, please contact support.

Setting the region through the Netlify UI applies to all functions on your site.

  1. Go to Project configuration Build & deploy Continuous deployment Functions region.
  2. Select Configure.
  3. Use the menu to select a new region.
  4. Confirm with Save.
  5. Redeploy your site to apply the new region configuration.

Old deploys will continue to use the region configuration from when they were deployed.

If your project has functions that need to run in different regions — for example, one function that processes data close to a database in Dublin while the rest of your functions run in Ohio — you can override the region per function in code. The function-level region takes precedence over the site-level region set in the UI.

With in-source configuration:

netlify/functions/eu-data.mts
import type { Config } from "@netlify/functions"
export default async (req: Request) => {
return new Response("Hello from Europe!")
}
export const config: Config = {
path: "/eu-data",
region: "dub",
}

With netlify.toml:

[functions.eu_data]
region = "dub"

This feature is available on Credit-based plans only.

By default, Netlify functions run with 1024 MB of memory and a proportional amount of compute. For workloads that need more resources to run reliably — such as processing large payloads or running AI inference — you can configure each function with either memory or vcpu.

Memory and vCPU scale together: pick more of one and you get more of the other. Set whichever maps more naturally onto how you think about your function — megabytes when memory pressure is the constraint, vCPUs when you care about compute — and Netlify sizes the other side automatically. The two are mutually exclusive; set one, not both.

With in-source configuration:

netlify/functions/heavy.mts
import type { Config } from "@netlify/functions"
export default async (req: Request) => {
return new Response("Doing more, faster")
}
export const config: Config = {
memory: "2gb", // or memory: 2048
path: "/heavy",
}

With netlify.toml:

[functions.heavy]
memory = "2gb"

The memory property accepts either a number of megabytes or a human-friendly string with a unit ("2gb", "1024mb", case-insensitive). Allowed range: 1024 to 4096 MB.

The vcpu property accepts a number between 0.5 and 2.0. The endpoints map to:

  • vcpu: 0.5 → 1024 MB
  • vcpu: 2.0 → 4096 MB

Values in between scale linearly.

For granular control over which files are bundled in your executable function artifacts, use the netlify.toml properties external_node_modules and included_files. Visit the file-based configuration doc for details.

[functions]
# Flags "package-1" as an external node module for all functions.
external_node_modules = ["package-1"]
# Includes all Markdown files inside the "files/" directory.
included_files = ["files/*.md"]

For all Node.js functions deployed on or after May 15, 2023, the default functions runtime is based on the Node.js version used for the build. The Node.js version used for the build must be a valid AWS Lambda runtime for Node.js that isn’t set to be deprecated in the next two months.

If the build uses a version of Node.js that does not meet these conditions, then the functions runtime uses a fallback default version of Node.js 22.

You can override the default to any valid AWS Lambda runtime for Node.js that isn’t set to be deprecated in the next two months. Do so by completing the following steps.

  1. In the Netlify UI, set the environment variable AWS_LAMBDA_JS_RUNTIME to the desired version. For example, to use Node.js 20 for all future functions deployed, set the variable value to nodejs20.x.

  2. Redeploy your site to apply the new runtime version.

Note that this environment variable must be set using the Netlify UI, CLI, or API, and not with a Netlify configuration file (netlify.toml).

Node.js supports two distinct module formats with different capabilities and APIs: ECMAScript modules (or ES modules), an official standard format for JavaScript packages, and CommonJS, a legacy format specific to Node.js.

The module format for each function is determined by the file extension of its entry file:

  • Files with .mts or .mjs extensions are always executed as ES modules.
  • Files with .cts or .cjs extensions are always executed as CommonJS.
  • Files with .ts or .js extensions are executed as ES modules if the closest package.json has "type": "module", otherwise as CommonJS.

Choosing a module format has implications for how you import npm packages:

  • CommonJS functions cannot use a static import for npm packages written as ES modules; use a dynamic import instead.
  • ES module functions cannot use named imports for npm packages written in CommonJS (for example, import { kebabCase } from "lodash"); use a default import (import _ from "lodash").
  • In ES modules, Node.js built-ins like __dirname and __filename are not available; use import.meta.url instead.

Default values

Unless customized, every function deploys with:

SettingDefaultConfigurable?
Regioncmh (US East, Ohio) 1Yes — Region
Memory1024 MBYes — Memory or vCPU
Synchronous execution limit60 secondsNo
Scheduled execution limit30 secondsNo
Background execution limit15 minutesNo
Buffered request/response payload6 MB 2No
Streamed response payload20 MBNo
Background request/response payload256 KBNo

  1. Sites created before October 4, 2023 may have a different default region. Check your current configuration in Project configuration Build & deploy Continuous deployment Functions region.
  2. Requests with binary payloads such as image uploads are Base64-encoded, which adds approximately 30% overhead — effectively reducing the binary request payload size limit to 4.5 MB.

Beyond these defaults, additional capabilities like Private Connectivity can be enabled by contacting your account manager.

Netlify will access the functions directory during every build, preparing and deploying each supported code file as a function. The default directory is YOUR_BASE_DIRECTORY/netlify/functions. You can customize the directory using the Netlify UI or file-based configuration.

[functions]
directory = "my_functions"

Settings in netlify.toml override settings in the Netlify UI.

For both methods, the path is an absolute path relative to the site’s base directory in your repository. To help keep your site secure, make sure your functions directory is outside of your publish directory so that your source files aren’t deployed as part of your site.

By default, every function is available at https://<YOUR DOMAIN>/.netlify/functions/<FUNCTION NAME>. Use the path property in the function’s config to route it to one or more custom URLs.

export default async (req, context) => {
const { city, country } = context.params
return new Response(`You're visiting ${city} in ${country}!`)
}
export const config = {
path: "/travel-guide/:city/:country",
}

When you set a custom path, the function is only available at that path — not at the default /.netlify/functions/<name> URL.

To configure multiple paths, set path as an array.

export const config = {
path: ["/cats", "/dogs"],
}

path supports the web platform URLPattern syntax for wildcards and named groups. Named groups are exposed to the function on context.params.

export const config = {
path: ["/sale/*", "/item/:sku"],
}

Use excludedPath to carve exceptions out of a path pattern. Accepts a single string or an array of strings, each starting with /.

export const config = {
excludedPath: ["/product/*.css", "/product/*.js"],
path: "/product/*",
}

By default, a function runs for any request to its configured paths regardless of whether static files exist there. To let static assets on the CDN win when they exist, set preferStatic: true.

export const config = {
path: ["/product/:sku", "/item/:sku"],
preferStatic: true,
}

By default, a function responds to every HTTP method. Use the method property to restrict it to specific methods.

export const config = {
method: ["GET", "POST"],
path: "/items",
}

This feature is available on all Pro and Enterprise plans.

Netlify offers several regions for deploying your serverless functions. You may want to customize the region for the following reasons:

  • Optimize performance. Deploying serverless functions close to their data sources, such as a database or another backend service, can greatly reduce roundtrip time for data retrieval resulting in faster response times for your users.
  • Ensure compliance. In some cases, data protection laws and industry-specific regulations may require that sensitive data processing happens within specific regions.
  • Use Private Connectivity. Static IP addresses for Private Connectivity are available in only some regions.

Regions are identified by airport code. By default, Netlify deploys functions for new sites to cmh (Ohio) — a common choice for many database providers, which optimizes performance for most cases.

You can change the region through the Netlify UI to any of the following:

Airport codeRegion
cmhUS East (Ohio)
dubEU (Ireland)
fraEU (Frankfurt)
gruSouth America (São Paulo)
iadUS East (N. Virginia)
lhrEU (London)
nrtAsia Pacific (Tokyo)
pdxUS West (Oregon)
sfoUS West (N. California)
sinAsia Pacific (Singapore)
sydAsia Pacific (Sydney)
yulCanada (Central)

In addition to the above self-serve regions, the following are available through support-assisted configuration:

Airport codeRegion
cdgEU (Paris)
mxpEU (Milan)

If you want your site to use one of the above regions, please contact support.

Setting the region through the Netlify UI applies to all functions on your site.

  1. Go to Project configuration Build & deploy Continuous deployment Functions region.
  2. Select Configure.
  3. Use the menu to select a new region.
  4. Confirm with Save.
  5. Redeploy your site to apply the new region configuration.

Old deploys will continue to use the region configuration from when they were deployed.

If your project has functions that need to run in different regions — for example, one function that processes data close to a database in Dublin while the rest of your functions run in Ohio — you can override the region per function in code. The function-level region takes precedence over the site-level region set in the UI.

With in-source configuration:

netlify/functions/eu-data.mjs
export default async (req) => {
return new Response("Hello from Europe!")
}
export const config = {
path: "/eu-data",
region: "dub",
}

With netlify.toml:

[functions.eu_data]
region = "dub"

This feature is available on Credit-based plans only.

By default, Netlify functions run with 1024 MB of memory and a proportional amount of compute. For workloads that need more resources to run reliably — such as processing large payloads or running AI inference — you can configure each function with either memory or vcpu.

Memory and vCPU scale together: pick more of one and you get more of the other. Set whichever maps more naturally onto how you think about your function — megabytes when memory pressure is the constraint, vCPUs when you care about compute — and Netlify sizes the other side automatically. The two are mutually exclusive; set one, not both.

With in-source configuration:

netlify/functions/heavy.mjs
export default async (req) => {
return new Response("Doing more, faster")
}
export const config = {
memory: "2gb", // or memory: 2048
path: "/heavy",
}

With netlify.toml:

[functions.heavy]
memory = "2gb"

The memory property accepts either a number of megabytes or a human-friendly string with a unit ("2gb", "1024mb", case-insensitive). Allowed range: 1024 to 4096 MB.

The vcpu property accepts a number between 0.5 and 2.0. The endpoints map to:

  • vcpu: 0.5 → 1024 MB
  • vcpu: 2.0 → 4096 MB

Values in between scale linearly.

To optimize bundling time and artifact size, you can have Netlify use esbuild for bundling your JavaScript functions. Enable this in netlify.toml.

[functions]
node_bundler = "esbuild"

For granular control over which files are bundled in your executable function artifacts, use the netlify.toml properties external_node_modules and included_files. Visit the file-based configuration doc for details.

[functions]
# Flags "package-1" as an external node module for all functions.
external_node_modules = ["package-1"]
# Includes all Markdown files inside the "files/" directory.
included_files = ["files/*.md"]

For all Node.js functions deployed on or after May 15, 2023, the default functions runtime is based on the Node.js version used for the build. The Node.js version used for the build must be a valid AWS Lambda runtime for Node.js that isn’t set to be deprecated in the next two months.

If the build uses a version of Node.js that does not meet these conditions, then the functions runtime uses a fallback default version of Node.js 22.

You can override the default to any valid AWS Lambda runtime for Node.js that isn’t set to be deprecated in the next two months. Do so by completing the following steps.

  1. In the Netlify UI, set the environment variable AWS_LAMBDA_JS_RUNTIME to the desired version. For example, to use Node.js 20 for all future functions deployed, set the variable value to nodejs20.x.

  2. Redeploy your site to apply the new runtime version.

Note that this environment variable must be set using the Netlify UI, CLI, or API, and not with a Netlify configuration file (netlify.toml).

Node.js supports two distinct module formats with different capabilities and APIs: ECMAScript modules (or ES modules), an official standard format for JavaScript packages, and CommonJS, a legacy format specific to Node.js.

The module format for each function is determined by the file extension of its entry file:

  • Files with .mts or .mjs extensions are always executed as ES modules.
  • Files with .cts or .cjs extensions are always executed as CommonJS.
  • Files with .ts or .js extensions are executed as ES modules if the closest package.json has "type": "module", otherwise as CommonJS.

Choosing a module format has implications for how you import npm packages:

  • CommonJS functions cannot use a static import for npm packages written as ES modules; use a dynamic import instead.
  • ES module functions cannot use named imports for npm packages written in CommonJS (for example, import { kebabCase } from "lodash"); use a default import (import _ from "lodash").
  • In ES modules, Node.js built-ins like __dirname and __filename are not available; use import.meta.url instead.

Default values

Unless customized, every function deploys with:

SettingDefaultConfigurable?
Regioncmh (US East, Ohio) 1Yes — Region
Memory1024 MBYes — Memory or vCPU
Synchronous execution limit60 secondsNo
Scheduled execution limit30 secondsNo
Background execution limit15 minutesNo
Buffered request/response payload6 MB 2No
Streamed response payload20 MBNo
Background request/response payload256 KBNo

  1. Sites created before October 4, 2023 may have a different default region. Check your current configuration in Project configuration Build & deploy Continuous deployment Functions region.
  2. Requests with binary payloads such as image uploads are Base64-encoded, which adds approximately 30% overhead — effectively reducing the binary request payload size limit to 4.5 MB.

Beyond these defaults, additional capabilities like Private Connectivity can be enabled by contacting your account manager.

Netlify will access the functions directory during every build, preparing and deploying each supported code file as a function. The default directory is YOUR_BASE_DIRECTORY/netlify/functions. You can customize the directory using the Netlify UI or file-based configuration.

[functions]
directory = "my_functions"

Settings in netlify.toml override settings in the Netlify UI.

For both methods, the path is an absolute path relative to the site’s base directory in your repository. To help keep your site secure, make sure your functions directory is outside of your publish directory so that your source files aren’t deployed as part of your site.

By default, every function is available at https://<YOUR DOMAIN>/.netlify/functions/<FUNCTION NAME>. To route a function to a custom URL, configure it in netlify.toml. Routing for Go functions is configured exclusively via netlify.toml.

[[redirects]]
from = "/travel-guide/*"
to = "/.netlify/functions/travel-guide"
status = 200

For more advanced routing — wildcards, query parameters, language detection, role-based rules — see the redirects documentation.

This feature is available on all Pro and Enterprise plans.

Netlify offers several regions for deploying your serverless functions. You may want to customize the region for the following reasons:

  • Optimize performance. Deploying serverless functions close to their data sources, such as a database or another backend service, can greatly reduce roundtrip time for data retrieval resulting in faster response times for your users.
  • Ensure compliance. In some cases, data protection laws and industry-specific regulations may require that sensitive data processing happens within specific regions.
  • Use Private Connectivity. Static IP addresses for Private Connectivity are available in only some regions.

Regions are identified by airport code. By default, Netlify deploys functions for new sites to cmh (Ohio) — a common choice for many database providers, which optimizes performance for most cases.

You can change the region through the Netlify UI to any of the following:

Airport codeRegion
cmhUS East (Ohio)
dubEU (Ireland)
fraEU (Frankfurt)
gruSouth America (São Paulo)
iadUS East (N. Virginia)
lhrEU (London)
nrtAsia Pacific (Tokyo)
pdxUS West (Oregon)
sfoUS West (N. California)
sinAsia Pacific (Singapore)
sydAsia Pacific (Sydney)
yulCanada (Central)

In addition to the above self-serve regions, the following are available through support-assisted configuration:

Airport codeRegion
cdgEU (Paris)
mxpEU (Milan)

If you want your site to use one of the above regions, please contact support.

Setting the region through the Netlify UI applies to all functions on your site.

  1. Go to Project configuration Build & deploy Continuous deployment Functions region.
  2. Select Configure.
  3. Use the menu to select a new region.
  4. Confirm with Save.
  5. Redeploy your site to apply the new region configuration.

Old deploys will continue to use the region configuration from when they were deployed.

If your project has functions that need to run in different regions — for example, one function that processes data close to a database in Dublin while the rest of your functions run in Ohio — you can override the region per function in netlify.toml. The function-level region takes precedence over the site-level region set in the UI.

[functions.eu_data]
region = "dub"

This feature is available on Credit-based plans only.

By default, Netlify functions run with 1024 MB of memory and a proportional amount of compute. For workloads that need more resources to run reliably — such as processing large payloads or running AI inference — you can configure each function with either memory or vcpu.

Memory and vCPU scale together: pick more of one and you get more of the other. Set whichever maps more naturally onto how you think about your function — megabytes when memory pressure is the constraint, vCPUs when you care about compute — and Netlify sizes the other side automatically. The two are mutually exclusive; set one, not both.

Configure per-function resources in netlify.toml:

[functions.heavy]
memory = "2gb"
# or: vcpu = 1.5

The memory property accepts either a number of megabytes or a human-friendly string with a unit ("2gb", "1024mb", case-insensitive). Allowed range: 1024 to 4096 MB.

The vcpu property accepts a number between 0.5 and 2.0. The endpoints map to:

  • vcpu: 0.5 → 1024 MB
  • vcpu: 2.0 → 4096 MB

Values in between scale linearly.

The Go version used in the deployment pipeline is determined by your site’s build image.

To modify the Go version used for your builds, change the build image for your site at Project configuration Build & deploy Continuous Deployment Build image selection.

Netlify will access the functions directory during every build, preparing and deploying each supported code file as a function. The default directory is YOUR_BASE_DIRECTORY/netlify/functions. You can customize the directory using the Netlify UI or file-based configuration.

[functions]
directory = "my_functions"

Settings in netlify.toml override settings in the Netlify UI.

For both methods, the path is an absolute path relative to the site’s base directory in your repository. To help keep your site secure, make sure your functions directory is outside of your publish directory so that your source files aren’t deployed as part of your site.