Home / Companies / Upstash / Blog / Post Details
Content Deep Dive

Next.js Edge API Routes and Serverless Redis on Vercel

Blog post from Upstash

Post Details
Company
Date Published
Author
Noah Fischer
Word Count
282
Language
English
Hacker News Points
-
Summary

Next.js 12.2 introduces Edge API Routes, enabling developers to run APIs at edge locations for reduced latency globally, which is particularly beneficial for applications requiring low-latency access worldwide. An example project is outlined where a basic API counts page views for each edge location, utilizing Upstash Global Redis to maintain low latency by replicating data across multiple regions. The project setup involves creating a Next.js application, installing the Upstash Redis client, and deploying the application to Vercel, which supports the Edge runtime. The code includes importing necessary modules, setting up a Redis instance, and configuring the API to increment view counts based on user location. Upon deployment, the API can be tested from various locations, demonstrating different view counts for each region, showcasing the functionality of Edge API Routes and the benefits of using Upstash for global data replication in reducing latency.