Products:
Redis
Stack:
Node.js
Use Case:
State Store
Languages:
TypeScript
Platforms:
Supabase
Publisher:

Upstash Redis in Supabase Edge Functions

Redis counter example that stores a hash of function invocation count per region.

Redis Database Setup

Create a Redis Database using Upstash Console or Upstash CLI.

Select the Global type to minimize the latency from all edge locations. Copy the UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN to your .env file. You'll find them under Details > REST API > .env

cp supabase/functions/upstash-redis-counter/.env.example supabase/functions/upstash-redis-counter/.env

Run locally

Make sure you have the latest version of the Supabase CLI installed.

supabase start
supabase functions serve upstash-redis-counter --no-verify-jwt --env-file supabase/functions/upstash-redis-counter/.env

Navigate to 'http://localhost:54321/functions/v1/upstash-redis-counter'.

Deploy

supabase functions deploy upstash-redis-counter --no-verify-jwt
supabase secrets set --env-file supabase/functions/upstash-redis-counter/.env

Learn More

To learn more about Upstash and its services, check out the following resources: