Quickstart
Install the SDK and create your first subscription in 5 minutes.
Quickstart
Installation
Releasing soon on npm. The @recur/sdk package is fully built and will be published to npm shortly. Stay tuned!
Initialize the client
Use getClusterDefaults to get the correct RPC URL, program ID, and USDC mint for your target cluster:
Or provide explicit values:
Subscribe a user
Build the instructions that create an on-chain subscription. The subscriber signs the resulting transaction in their wallet — no backend signature needed.
The returned instructions array contains exactly two instructions:
- SPL Token
approve— delegatesamount × delegationCycles(default 12) to the Subscription PDA initialize_subscription— creates the on-chain PDA with amount, interval, and plan seed
Or use the high-level subscribe method
This builds, signs, confirms, and registers the subscription in one call.
What happens next
Once the subscription is created on-chain:
- The first payment is processed immediately — no waiting for the billing interval
- The Keeper detects the subscription and registers it in the database (your
frontend can also call
registerSubscriptiondirectly with the subscriber JWT) - After each subsequent billing interval elapses, the Keeper calls
process_payment - Funds are pulled from the subscriber's wallet: net amount to the merchant, platform fee to the treasury
- A webhook fires to the merchant's registered endpoint with payment details
When the SPL approve runs out (after delegationCycles payments), call
buildReapproveTransaction
to top it up — no on-chain subscription state is touched.
@recur/react — Coming Soon. A React package with RecurProvider, SubscribeButton, and hooks is planned. For now, use @recur/sdk directly as shown above.