Core Features
Data Fetching
Next.js offers to the option to create API endpoints and execute back-end logic without much configuration. All API endpoints that defined are deployed as serverless functions, and are only executed when invoked.
By default, API routes use the Node.js runtime, a JavaScript runtime for running server-side code, to execute logic. Due to this, serverless functions can only be deployed in one region at a time, which might cause end-users to experience higher latency based on their location in the world. Serverless functions may also suffer from cold starts, if they aren't invoked on a regular basis. However, Next.js provides the ability to opt-in to using the Edge runtime to get around some of the downsides to serverless functions. Edge functions will execute code as close as possible to end-users, without suffering from cold starts and increased latency.
Quote:
Author:
Timer: 0ms
Quote:
Author:
Timer: 0ms
For demonstration purposes, the Node.js serverless functions have been deployed to Paris. This is to help illustrate how users who do not live in the same region as deployed serverless functions, will undergo increased latency. Whereas with edge functions, there is minimal latency.