Vercel, the developer behind the Next.js framework, has announced Edge Functions, now generally available (GA) to all customers.

According to the introduction, Vercel Edge Functions are JavaScript, TypeScript or WebAssembly functions, which are usually more efficient and faster than traditional Serverless compute because they run in a more streamlined runtime. Deployed globally by default, Edge Functions run in the region closest to the request to minimize latency.


// pages/api/hello.ts
export const config = {
  runtime: 'edge'
}

export default function handler(req: Request) {
  return new Response("Hello World");
}

Unlike Edge Middleware, Functions run after caching; thus being able to both cache and return a response, ideal for data fetching or rewriting. Vercel Edge Functions are natively supported by Next.js and many other frameworks such as Nuxt, Astro, and SvelteKit. Edge Functions can also be created as standalone functions in the Vercel CLI.

Vercel launched a public beta of Edge Functions last summer. And claims that during testing, its Edge Network has seen more than 30 billion Edge Function calls. Since beta, Vercel has added the ability to place Edge Functions into specific regions, added support for WebAssembly, and improved performance.

Edge Functions uses the lightweight Edge Runtime, which is built on the V8 engine used by the Chrome browser and does not run inside the MicroVM. Vercel’s own open source OG Image Generation project utilizes Edge Functions for global fast computation. Its data shows that the cost of generating one million images with OG Image Generation running in Edge Functions is nearly 15 times lower than the cost of generating the same million images with Serverless Functions.

Currently, the company is also improving the compatibility between Edge Functions and Serverless Functions. Their goal is for the Edge Runtime to be an appropriate subset of the Node.js API, with the hope that users will be able to choose their execution environment based on performance and cost characteristics rather than the API. As well as work on improving the observability and error reporting of functions, working towards seamless interoperability, and more.

Edge Functions are billed in units of 50 milliseconds of CPU time per call, called execution units. Hobbyists get 500,000 Edge Function execution units per month for free. Pro and Enterprise teams are free with 1 million Edge Function execution units per month and can add additional usage.

More details can be found in the official announcement.

#Nextjs #developer #Vercel #officially #launched #Edge #Functions #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *