@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>
/app/page.tsx
import { Redis } from "@upstash/redis"; const redis = Redis.fromEnv(); export default async function Home() { const count = await redis.incr("counter"); return ( <div className="flex h-screen w-screen items-center justify-center"> <h1 className="text-4xl font-bold">Counter: {count}</h1> </div> ) }
npm run dev
http://localhost:3000/
vercel
Was this page helpful?