Next.js App Router
/

Learn how to build a SaaS with Next.js App Router and Supabase

Permissions and Quotas

In this lesson, we learn how to ensure users respect the limits and quotas according to their Stripe subscription

Reading Time: 44 minutes

Now that we can create Stripe subscriptions, we need to make sure that users respect the limits and quotas according to their Stripe subscriptions. To do so, we need to establish some thresholds and enforce them, which we will do in this lesson.

Guarding the content generation API with thresholds

There are two instances where we need to guard the content generation API with thresholds:

  1. Titles - We need to make sure that the user has enough tokens to generate a list of titles before streaming the content
  2. Content - We need to make sure that the user has enough tokens to generate the content

At the same time, we also need to report the tokens used by the user to the databa ...