Menu

Upstash Integration

Upstash is a serverless data infrastructure service that provides hosted Redis and Kafka services with low latency, high availability, and global distribution.

In complex commercial projects, Redis is often essential, mainly used to implement cache, rate limiting, and other business logic-related functions.

To accommodate different use cases, Nexty.dev template encapsulates Redis and rate limiter with flexible compatibility design:

  • If Upstash environment variables are configured, it supports calling the encapsulated Redis and rate limiter methods
  • If Upstash environment variables are not configured, related functions will automatically degrade without affecting other business logic

To help you get started faster, the template includes a rate limiter example in the email subscription feature. It automatically determines whether to enable rate limiting based on whether Upstash environment variables are configured.

In this chapter, we'll complete the registration and configuration of Upstash.

Registration and Basic Configuration

  1. Visit Upstash and register an account using your email

  2. Enter the Dashboard page and click the Create database button

Create database

Create database

Create database

  1. Enter the database details page, copy UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN from the REST API section to environment variables

upstash api

Verification

Now you can try submitting an email subscription in the page Footer again, and check the Upstash Redis Data Browser page. If there's new data, it indicates that the subscription rate limiter is working.

upstash data browser