Database Setup
Create a Redis database using Upstash Console or Upstash CLI.Project Setup
We will use C3 (create-cloudflare-cli) command-line tool to create our application. You can open a new terminal window and run C3 using the prompt below.The Code
Here is a Worker template to configure and test Upstash Redis connection.Configure Credentials
Navigate to Upstash Console and copy/paste yourUPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
to your wrangler.toml
as below.
Test and Deploy
You can test the function locally withnpx wrangler dev
Deploy your function to Cloudflare with npx wrangler deploy
The endpoint of the function will be provided to you, once the deployment is done.