Overview
Get started with web billing in TurboStarter.
The @workspace/billing and @workspace/billing-web packages are used to manage all the billing-related logic and features for your web SaaS application.
Inside, we're making an abstraction layer that allows us to use different billing providers without breaking our code nor changing the internal API calls.

Providers
TurboStarter implements multiple providers for managing billing:
Stripe
The most popular and customizable billing provider.
Lemon Squeezy
A Merchant of Record (MoR) solution recently acquired by Stripe.
Polar
A developer-first billing provider with a focus on SaaS businesses.
Creem (coming soon)
A billing provider for SaaS businesses.
All configuration and setup is built-in with a unified API, so you can switch between providers by simply changing the exports and even introduce your own provider without breaking any billing-related logic.
Depending on the service you use, you will need to set the environment variables accordingly. By default - the billing package uses Stripe. Alternatively, you can use Lemon Squeezy or Polar. In the future, we will also add Creem.
Configuration
The core billing configuration is maintained in the @workspace/billing package within the config directory. This directory houses the primary configuration schema as well as schemas for the available API endpoints.
To better understand all billing features and customization options provided by TurboStarter, explore the following dedicated guides:
Configuration
Learn how to structure billing settings for your app, plan details and features.
Subscriptions
Set up and manage recurring billing cycles, trial periods, and upgrade/downgrade logic.
One-time
Handle single, non-recurring payments, such as purchases or one-off charges.
Credits
Implement a system for pre-paid credits, allowing users to consume features based on available balance.
Metered usage
Track and invoice customers based on actual usage, ideal for pay-as-you-go models.
Per-seat
Charge customers based on user count, perfect for teams or organizations with varying members.
Webhooks
Handle webhooks from your billing provider and manage payment statuses.
Fetching customer status
After your user completes checkout, you'll often want to fetch their current billing summary (subscription status, entitlements, credits) to:
- gate features in your UI
- show “Current plan” / “Manage subscription” states
- keep the app in sync after upgrades/downgrades
You can do this via the billing me endpoint (/api/billing/me) using the web API client.
Server-side
import { handle } from "@workspace/api/utils";
import { getActivePlan } from "@workspace/billing";
import { api } from "~/lib/api/server";
export default async function BillingStatus() {
const summary = await handle(api.billing.me.$get)();
const plan = getActivePlan(summary);
return <p>Current plan: {plan}</p>;
}Client-side
"use client";
import { useQuery } from "@tanstack/react-query";
import { handle } from "@workspace/api/utils";
import { getActivePlan } from "@workspace/billing";
import { api } from "~/lib/api/client";
export function BillingStatus() {
const summary = useQuery({
queryKey: ["me"],
queryFn: handle(api.billing.me.$get),
});
if (!summary.data) {
return null;
}
const plan = getActivePlan(summary.data);
return <p>Current plan: {plan}</p>;
}In summary, TurboStarter offers a flexible and unified billing framework, allowing you to mix and match billing models and providers as needed. Each section above provides focused documentation to help you configure the approach that best suits your SaaS application's needs.
How is this guide?
Last updated on