Autumn Billing
Autumn is open source infrastructure to run SaaS pricing plans. It sits between your app and Stripe, and acts as the database for your customers' subscription status, usage metering and feature permissions.
Get help on Autumn's Discord
We're online to help you with any questions you have.
Features
- One function for all checkout, subscription and payment flows
- No webhooks required: query Autumn for the data you need
- Manages your application's free and paid plans
- Usage tracking for usage billing and periodic limits
- Custom plans and pricing changes through Autumn's dashboard
Setup Autumn Account
First, create your pricing plans in Autumn's dashboard, where you define what each plan and product gets access to and how it should be billed. In this example, we're handling the free and pro plans for an AI chatbot, which comes with a number of messages
per month.
Install Autumn SDK
If you're using a separate client and server setup, make sure to install the plugin in both parts of your project.
Add AUTUMN_SECRET_KEY
to your environment variables
You can find it in Autumn's dashboard under "Developer".
Add the Autumn plugin to your auth
config
Autumn will auto-create your customers when they sign up, and assign them any default plans you created (eg your Free plan)
Add <AutumnProvider />
Client side, wrap your application with the AutumnProvider component, and pass in the baseUrl
that you define within better-auth's authClient
.
Usage
Handle payments
Call attach
to redirect the customer to a Stripe checkout page when they want to purchase the Pro plan.
If their payment method is already on file, AttachDialog
will open instead to let the customer confirm their new subscription or purchase, and handle the payment.
Make sure you've pasted in your Stripe test secret key in the Autumn dashboard.
The AttachDialog component can be used directly from the autumn-js/react
library (as shown in the example above), or downloaded as a shadcn/ui component to customize.
Integrate Pricing Logic
Integrate your client and server pricing tiers logic with the following functions:
check
to see if the customer isallowed
to send a message.track
a usage event in Autumn (typically done server-side)customer
to display any relevant billing data in your UI (subscriptions, feature balances)
Server-side, you can access Autumn's functions through the auth
object.
Additional Functions
openBillingPortal()
Opens a billing portal where the customer can update their payment method or cancel their plan.
cancel()
Cancel a product or subscription.
Get invoice history
Pass in an expand
param into useCustomer
to get additional information. You can expand invoices
, trials_used
, payment_method
, or rewards
.