Configure and deploy functions

This document will help you get started with Netlify 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 function sources, including background functions. Netlify will access this directory during every deploy, zipping and deploying each supported code file as a function.

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 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 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 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 functions built with JavaScript, TypeScript, and Go. Visit our build with JavaScript, TypeScript, and Go docs to learn more.

# Deploy functions

You can use continuous deployment, the Netlify CLI, or the Netlify API to deploy functions.