Vercel Functions
This is a quickstart for Vercel Serverless Functions. For Vercel Edge Functions, check this article.
Database Setup
Create a Redis database using Upstash Console or
Upstash CLI. Select the same region with your
Vercel Serverless Function to minimize the latency. Copy the
UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
for the next steps.
Project Setup
We will create a Next.js application and deploy to Vercel.
Install @upstash/redis:
The Code
Update app/api/hello.js
with the template below to test the Redis client:
Configure the Credentials
We’ll place the credentials in the .env
file as below:
Run & Deploy
You can run the app locally: npm run dev
and check
http://localhost:3000/api/hello
Deploy your app with vercel deploy
You can also integrate your Vercel projects with Upstash using Vercel Integration module. Check this article.
Was this page helpful?