Edge Handlers overview

This feature is in early access BETA.

Edge Handlers allow you to dynamically affect traffic to and from your site and personalize your visitors’ site experience through programmable routing. As powerful scripts that run directly from our CDN edge nodes, Edge Handlers go beyond what our static routing is capable of. Edge Handlers can:

  • filter incoming HTTP requests
  • manipulate HTTP requests and responses

To get started using Edge Handlers, visit our sign-up form to request an early access invitation. Go to our Forums to join the conversation about Edge Handlers.

# Use cases for Edge Handlers vs. Functions

Although both Edge Handlers and Netlify Functions help you build dynamic web experiences, there are a few differences in their architecture and application that make Edge Handlers a better fit for certain use cases.

  • Edge Handlers have the ability to intercept incoming requests in order to transform them or route them based on information available in the request, whereas Functions cannot be used to intercept the request-response cycle.
  • Edge Handlers are invoked on requests to your site unlike Netlify Functions, which work as API endpoints.
  • Because Edge Handlers run on the CDN edge node closest to the user, they have lower latency than serverless functions, which run on third-party servers in a single region.

These differences mean Edge Handlers are better suited than Functions for quick dynamic routing decisions like the following:

  • Localizing content. Populate local language and branding into your website using the Geolocation API.
  • Customizing authentication. Deliver fast, customized authentication with credentials cached and verified at the edge.
  • Personalizing ads. Serve higher-converting ads that tailor content based on each user’s location and other details such as cookies or authentication tokens.

It often makes sense for a site to use both Edge Handlers and Functions. Consider an e-commerce site where products available for purchase vary by location and customers gain access to certain promotional deals through a loyalty program with different user tiers. You can use Edge Handlers to quickly route a visitor to the right store for their location and display personalized ads for promotions available to their user. Then you can use Functions for the purchase checkout to access payment services and update your inventory database.

# Operation limits

By default, Edge Handlers have limits for the amount of memory and execution time they can use:

  • memory limit: 256 megabytes
  • execution time limit: 50 milliseconds

An Edge Handler may run up against the memory limit, for example, while transforming a large response body. If a handler goes over a limit, it will terminate abruptly, and the request will fail to complete. If you want additional memory and execution time to run your Edge Handlers, please contact sales.

# More Edge Handlers resources