Skip to content

Edge Functions APIBeta

Learn about the Edge Runtime and available APIs when working with Edge Functions

Edge Functions use the Edge Runtime, a runtime that is built on top of V8. The Edge Runtime exposes a subset of Web Standard APIs such as FetchEvent, Response, and Request.

These native Web API objects are extended to give you more control over how you manipulate and configure a response, based on the incoming requests.

The Edge Runtime can execute V8 code, but doesn't have access to native Node.js APIs such as process, path, or fs.

Instead, you have access to Web APIs like fetch, request, and response.

You can use process.env to access Environment Variables.

The Edge Runtime has some restrictions including:

  • Native Node.js APIs are not supported. For example, you can't read or write to the filesystem
  • node_modules can be used, as long as they implement ES Modules and do not use native Node.js APIs
  • Calling require directly is not allowed. Use ES Modules instead

The following JavaScript language features are disabled, and will not work:

  • eval: Evaluates JavaScript code represented as a string
  • new Function(evalString): Creates a new function with the code provided as an argument

See Edge Middleware Limitations for more information on these limitations.