As a prerequisite, you will require Convex version 1.25.0 or higher. Additionally, if you already have
autumn-js
installed, it will need to be version 0.1.24 or higher.Setup
1. Install the npm packages
2. Set the Autumn secret key in your convex environment
3. Add the component to your application
Add the autumn convex component to yourconvex/convex.config.ts
convex/convex.config.ts
4. Initialize the Autumn client
Paste the following code intoconvex/autumn.ts
The
identify()
function determines which customer is making the request. You may customise it based on your use case. For example, if organizations are your customers, you should return an organization ID as customerId
. This can help you with
entity billing.In the
identify()
function, you may need to change user.subject
to user.id
depending on your auth provider.5. Setting up <AutumnProvider/> on your frontend
This allows your React app to make use of our hooks and components. To do this, add the following to a fileAutumnWrapper.tsx
:
If you’re using Autumn purely on the backend, you may skip this step.
Using Autumn hooks and components on the frontend
<PricingTable/>
The quickest way to get started is to use our <PricingTable/> component:
src/app/page.tsx
Our components can be downloaded as shadcn components and are fully customizable. You can learn how to do so here
useCustomer
We also provide a useCustomer
hook which lets you easily access your customer data and interact with the Autumn API directly from your frontend. For example, to upgrade a user:
src/app/page.tsx
useCustomer()
and useEntity()
features as you would normally. If you aren’t familiar with these,
you can read more about them here.
Using Autumn on the backend
You will also need to use Autumn on your backend for actions such as tracking or gating usage of a feature. To do so, you can use our Autumn client:Check feature access
Track feature usage
These are the most common functions you’ll be using, but we also export all other functions in our JS SDK / API reference, for eg:
checkout
attach
And more!
- Learn how to make credits-based pricing models with Autumn
- Learn how to make prepaid pricing models with Autumn