Contents

About edge function

   Jun 24, 2023     1 min read

This is a post about the Edge function.

What is an edge function?

An edge function is a serverless computing function that runs in a cloud environment. They are typically used as part of a cloud service, such as a web application or API.

I’ll focus on Vercel and NextJS, which I use at my company.

Vercel
What is Vercel?

Vercel is a serverless platform for static websites and single-page applications (SPAs). Vercel’s AS Function is a form of Serverless Functions provided by this platform.

Vercel Edge function

A small piece of code that runs in a cloud environment and is used to generate and process responses to specific HTTP requests. It is an implementation of Function-as-a-Service (FaaS), one of the core concepts of serverless architecture.

It can be used in conjunction with other features of Vercel, and can be used to develop and deploy the full functionality of applications hosted alongside static websites.

NextJS
What is NextJS?

It is a React-based framework that supports server-side rendering (SSR), static site generation, client-side routing, and more. In Next.js, AdsFunction is a feature that allows you to implement and execute backend logic using serverless functions.

NextJS Edge function

is implemented by creating an API route. You create a file with a .js or .ts extension, and within that file you write the logic for the API endpoint. This file is built with your Next.js application, and the generated API endpoints can be called by clients or other parts of your application. In addition, you can implement backend logic within your Next.js application, interact with databases, call external APIs, authenticate and authorize, upload files, and more. This gives your Next.js application full integration between client and server, and it can handle many different kinds of data requests.