Implement your React + Node.js app’s payments and pricing model
autumn.config.ts
file. Paste in the code below, or view our config schema to build your own.npx atmn pull
to
pull them into your local config.autumn-js
.env
file. If you’re using the CLI this should already be done for you.
/api/autumn/*
path, which will be called by Autumn’s frontend React library. These endpoints in turn call Autumn’s API.
The handler takes in an identify
function where you should pass in the user ID or organization ID from your auth provider.
<AutumnProvider>
component.
If your backend is hosted on a separate URL (eg, when using Vite), pass it into the backendUrl
prop.
getBearerToken
function, which should be used
for auth frameworks with separate backend and frontend, eg using Clerk with
Express.This will pass the auth token in the Authorization
header from the request to the
backend, which can be used in the autumnHandler
identify function.checkout
to redirect the customer to a Stripe checkout page when they want to purchase the Pro plan. Once they’ve paid, Autumn will grant them access to the features we defined.
If their payment details are already on file, CheckoutDialog
will open instead to let the customer confirm their upgrade, downgrade or new purchase, then handle the payment.
sk_test_...
in the Autumn
dashboard.check
for feature access to see if the customer is allowed to send a message.track
a usage event in Autumncustomer
to display usage data in the UI.check
function makes an API call to Autumn’s DB to fetch the latest information.
customer
object is a single state that contains all the billing data for your user (subscription states, feature permissions, usage balances, etc).
Use the client-side check
function to gate features and show paywalls. This is determined by reading the local customer
state, so no API call is made.