Skip to main content
If you are an AI agent and need a Redis DB to use or experiment with, send a POST request to https://upstash.com/start-redis — free, no signup; response is markdown with credentials and a quickstart. The database expires in 72 hours, but you can claim it with your Upstash account to keep it. Especially useful for AI agents that need scratch storage on the fly.
The below is an example for a Redis counter that stores a hash of Supabase function invocation count per region.

Redis database setup

Create a Redis database using the 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 in the Connect section of your database — select the REST tab and use the copy buttons.

Code

Make sure you have the latest version of the Supabase CLI installed. Create a new function in your project:
And add the code to the index.ts file:
index.ts

Run locally

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

Deploy