What are Edge Functions?
Vercel introduced Edge functions to achieve CDN’s speed and server-side’s flexibility. Edge functions enable developers to run their code at the servers distributed globally. This means that your code will be executed in a more convenient location for your user. This allows developers to move server-side logic to the edge, closer to the origin of your visitor, for faster response time.
If you’ve ever used serverless functions, the above definition may sound familiar.
Edge Functions and Middleware in Next JS
Next JS is a React-based full-stack framework developed by Vercel that enables functionalities like pre-rendering of web pages. Unlike traditional react apps where the entire app is loaded on the client. Next.js allows the web page to be rendered on the server, which is great for performance and SEO.
Until recently, there were primarily two methods for serving content to the user’s browser:
- Statically from a Content Delivery Network close to the user’s location for faster response time.
- Dynamically with different content and logic on each request from a single server.
- Both methods have limitations, such as the CDN’s inability to cache dynamic content and the server’s inability to match the CDN’s delivery speed.
Contact Us