Configure and deploy Functions

This document will help you get started with Functions. You can explore real-world serverless function code examples and tutorials to get inspired. Visit our Forums to join the conversation about Functions.

# Configure the functions folder

To get started, designate a directory in your repository where Netlify can find your serverless functions, including background functions. Netlify will access this directory during every deploy, zipping and deploying each supported code file as a serverless Lambda function on AWS.

Default directory

If you choose not to designate a directory, Netlify will deploy Functions you save in YOUR_BASE_DIRECTORY/netlify/functions.

In the Netlify web interface, go to Site settings > Functions and enter a path to the directory in your repository where your serverless functions will be stored.

You can also set this by adding a [functions] section with a directory property to your Netlify configuration file. (Settings in netlify.toml override settings in the web interface.)

  directory = "my_functions"

The path is relative to the site’s base directory in your repository. You can deploy serverless functions with your site using either Netlify CLI or continuous deployment. If you’ve specified a build command for your site and you’re using continuous deployment, Netlify will run the build command before accessing your functions folder. This has the following implications:

  • You can use your preferred workflow and tools for developing your serverless functions, then compile at build time to single files in the designated functions directory.
  • You can access Netlify environment variables to inject API keys or other information you don’t want to store in your repository.

    Environment variable limits

    Because Netlify Functions are powered by AWS Lambda, AWS’s environment property limits apply to environment variables used with Netlify Functions.

  • Though we process the files in the functions directory after running your build command, the directory is not visible over the web unless you place it in your site’s publish directory (not recommended).

# Languages and language settings

Currently, you can deploy serverless functions built with JavaScript, TypeScript, and Go. Visit our build with JavaScript, TypeScript, and Go docs to learn more.

# Unbundled JavaScript function deploys

You can deploy unbundled JavaScript functions. Visit our docs about building serverless functions with JavaScript or manual deploys with the CLI to learn more.