Skip to content

Runtimes transform your source code into Serverless Functions, which are served by our Edge Network. Vercel supports four official Runtimes:

Runtime
Description
The Node.js Runtime takes an entrypoint of a Node.js function, builds its dependencies (if any) and bundles them into a Serverless Function.
The Go Runtime takes in a Go program that defines a singular HTTP handler and outputs it as a Serverless Function.
The Python Runtime takes in a Python program that defines a singular HTTP handler and outputs it as a Serverless Function.
The Ruby Runtime takes in a Ruby program that defines a singular HTTP handler and outputs it as a Serverless Function.
Note: In most cases, Runtime configuration is not necessary. See the Vercel Introduction documentation or the Serverless Functions documentation for more information.

By default, no configuration is needed to deploy Serverless Functions to Vercel.

For all officially supported languages (see below), the only requirement is creating a api directory and placing your Serverless Functions inside.

File Extensions
Language
.js, .ts
Node.js
.go
Go
.py
Python
.rb
Ruby

In order to customize the Memory or Maximum Execution Duration of your Serverless Functions, you can use the functions property.

If you would like to use a language that Vercel does not support by default, you can use a Community Runtime by setting the functions property in vercel.json:

vercel.json
{
  "functions": {
    "api/test.php": {
      "runtime": "vercel-php@0.1.0"
    }
  }
}

The following Community Runtimes are recommended by Vercel:

Note: If you would like to create a Community Runtime, see the Developing Your Own Runtime section.

You can extending the feature-set of a Vercel deployment by creating a Runtime that takes a list of files and outputs either static files or dynamic Serverless Functions.

A full API reference is available to help with creating Runtimes.

A runtime can retain an archive of up to 100mb of the filesystem at build time. The cache key is generated as a combination of:

  • Project name.
  • Team ID or User ID.
  • Entrypoint path (e.g., api/users/index.go).
  • Runtime identifier including version (e.g.: @vercel/go@0.0.1).

The cache will be invalidated if any of those items changes. You can bypass the cache by running vercel -f.

Most Runtimes use static analysis to determine which source files should be included in the Serverless Function output based on the build src input. Any unused code or assets is ignored to ensure your Serverless Function is as small as possible.

For example, the Node Runtime looks at calls to require() or fs.readFile() in order to determine which files to include automatically.

api/hello.js

import { readFileSync } from 'fs';
import path from 'path';

export default function handler(req, res) {
  const file = path.join(process.cwd(), 'files', 'test.json');
  const stringified = readFileSync(file, 'utf8');

  res.setHeader('Content-Type', 'application/json'));
  return res.end(stringified);
}

api/index.js file reads the contents of files/test.json.

In some cases, you may wish to include templates or views that are not able to be statically analyzed. Runtimes provide a configuration for includeFiles that accepts a glob of files that will always be included in the Serverless Functions output.

vercel.json
{
  "functions": {
    "api/test.js": {
      "includeFiles": "templates/**"
    }
  }
}

Using the default Node.js language and configuring the includeFiles within a vercel.json configuration file.

  • Runtimes can run for a maximum of 5 minutes before the execution times out.
  • The maximum cache archive size of a Runtime is 100mb.
  • The cache TTL is 7 days.