Menu
Important
Stay updated on React2Shell

Using the Node.js Runtime with Vercel Functions

Last updated December 1, 2025

You can create Vercel Function in JavaScript or TypeScript by using the Node.js runtime. By default, the runtime builds and serves any function created within the directory of a project to Vercel.

Node.js-powered functions are suited to computationally intense or large functions and provide benefits like:

  • More RAM and CPU power: For computationally intense workloads, or functions that have bundles up to 250 MB in size, this runtime is ideal
  • Complete Node.js compatibility: The Node.js runtime offers access to all Node.js APIs, making it a powerful tool for many applications

In order to use the Node.js runtime, create a file inside the directory with a function using the Web Standard export. No additional configuration is needed:

Alternatively, you can export each HTTP method as a separate export instead of using the Web Standard export:

To learn more about creating Vercel Functions, see the Functions API Reference. If you need more advanced behavior, such as a custom build step or private npm modules, see the advanced Node.js usage page.

The entry point for must be a glob matching , , or files** that export a default function.

Vercel Functions using the Node.js runtime support all Node.js APIs, including standard Web APIs such as the Request and Response Objects.

To learn more about the supported Node.js versions on Vercel, see Supported Node.js Versions.

For dependencies listed in a file at the root of a project, the following behavior is used:

  • If or is present, is executed
  • If is present is executed
  • If is present, is executed
  • If is present, is executed
  • If is present, is executed
  • Otherwise, is executed

If you need to select a specific version of a package manager, see corepack.

The Node.js runtime supports files ending with inside of the directory as TypeScript files to compile and serve when deploying.

An example TypeScript file that exports a Web signature handler is as follows:

You can use a file at the root of your project to configure the TypeScript compiler. Most options are supported aside from "Path Mappings" and "Project References".

Each request to a Node.js Vercel Function gives access to Request and Response objects. These objects are the standard HTTP Request and Response objects from Node.js.

Vercel additionally provides helper methods inside of the Request and Response objects passed to Node.js Vercel Functions. These methods are:

methoddescriptionobject
An object containing the request's query string, or if the request does not have a query string.Request
An object containing the cookies sent by the request, or if the request contains no cookies.Request
An object containing the body sent by the request, or if no body is sent.Request
A function to set the status code sent with the response where must be a valid HTTP status code. Returns for chaining.Response
A function to set the content of the response where can be a , an or a .Response
A function to send a JSON response where is the JSON object to send.Response
A function to redirect to the URL derived from the specified path with status code "307 Temporary Redirect".Response
A function to redirect to the URL derived from the specified path, with specified HTTP status code.Response

The following Node.js Vercel Function example showcases the use of , and helpers:

Example Node.js Vercel Function using the , , and helpers. It returns greetings for the user specified using .

If needed, you can opt-out of Vercel providing using advanced configuration.

We populate the property with a parsed version of the content sent with the request when possible.

We follow a set of rules on the header sent by the request to do so:

headerValue of
No header
An object representing the parsed JSON sent by the request.
An object representing the parsed data sent by with the request.
A string containing the text sent by the request.
A Buffer containing the data sent by the request.

With the helper, you can build applications without extra dependencies or having to parse the content of the request manually.

The helper is set using a JavaScript getter. In turn, it is only computed when it is accessed.

When the request body contains malformed JSON, accessing will throw an error. You can catch that error by wrapping with :

Catching the error thrown by with .

Request cancellation must be enabled on a per-route basis. See Functions API Reference for more information.

You can listen for the event on the request object to detect request cancellation:

Express.js is a popular framework used with Node.js. For information on how to use Express with Vercel, see the guide: Using Express.js with Vercel.

The Node.js runtime can be used as an experimental feature to run middleware. To enable, add the flag to your file:

Then in your middleware file, set the runtime to in the object:

Running middleware on the Node.js runtime incurs charges under Vercel Functions pricing. These functions only run using Fluid compute.


Was this helpful?

supported.