For the complete documentation index, see llms.txt. Prefer markdown by appending.mdto documentation URLs or sendingAccept: text/markdown.
Plan access
Paid feature access using the included plan checks, with customer ownership, subscription status, and direct server verification.
Paid features need an access rule at the operation that provides the result. Edge Kit includes plan middleware that combines the customer's session with their current subscription, so you can require a minimum tier for a feature.
Your UI can show an upgrade prompt, while the server remains responsible for allowing the operation.
Server functions
This example adds Premium access to the customer-owned notes function from protected calls:
import { createServerFn } from "@tanstack/react-start";
import { enforcePlan } from "@/lib/auth/middleware";
import { BillingPlan } from "@/lib/billing/types";
import { noteIdSchema } from "./notes.schema";
import { findNote } from "./notes.server";
export const getPaidNote = createServerFn({ method: "GET" })
.middleware([enforcePlan(BillingPlan.PREMIUM)])
.validator(noteIdSchema)
.handler(({ data, context }) => findNote(context.user.id, data.id));The middleware verifies the session and minimum plan before the handler runs. Keep the ownership check in the data query: a paid account still cannot read another customer's records.
HTTP endpoints
Apply the same plan check to an HTTP handler when it performs paid work, including streaming AI requests or exports. The protected calls guide includes the HTTP pattern.
Checking only the page leaves the underlying endpoint available to direct callers.
Subscription policy
Active subscriptions and trials grant their configured tier. Missing, inactive, or unrecognized subscriptions use Free access. The catalog's order defines the tier hierarchy.
A scheduled cancellation can retain access through the current period. Past-due subscriptions do not receive a grace period by default; adapt the policy if your offer includes one.
Usage limits
A tier check controls access to a feature. Project allowances, storage budgets, and AI spending also need a usage check in the operation that consumes them.
How is this guide?
Last updated on