Configuring the Runtime for Vercel Functions
The runtime of your function determines the environment in which your function will execute. Vercel supports various runtimes including Node.js, Python, Ruby, and Go. You can also configure other runtimes using the file. Here's how to set up each:
By default, a function with no additional configuration will be deployed as a Vercel Function on the Node.js runtime.
If you're not using a framework, you must either add
"type": "module" to your
package.json or change your JavaScript Functions'
file extensions from .js to
.mjs
For Go, expose a single HTTP handler from a file within an directory at your project's root. For example:
For Python, create a function by adding the following code to :
For Ruby, define an HTTP handler from files within an directory at your project's root. Ruby files must have one of the following variables defined:
- proc that matches the signature
- class that inherits from the class
For example:
Don't forget to define your dependencies inside a :
You can configure other runtimes by using the property in your file. For example:
In this case, the function at would use the custom runtime specified.
For more information, see Community runtimes
Was this helpful?