@upstash/redis
npx create-next-app@latest cd my-app npm install @upstash/redis
UPSTASH_REDIS_REST_URL
UPSTASH_REDIS_REST_TOKEN
.env
UPSTASH_REDIS_REST_URL=<YOUR_URL> UPSTASH_REDIS_REST_TOKEN=<YOUR_TOKEN>
/pages/api/hello.ts
import { Redis } from "@upstash/redis"; import type { NextApiRequest, NextApiResponse } from "next"; const redis = Redis.fromEnv(); export default async function handler( req: NextApiRequest, res: NextApiResponse, ) { const count = await redis.incr("counter"); res.status(200).json({ count }); }
npm run dev
http://localhost:3000/api/hello
vercel
Was this page helpful?