Hooks
Headless React hooks for fully custom subscribe, cancel, and re-approve UIs.
Coming Soon. @recur/react is currently in development. The hooks documented below represent the planned API. Use @recur/sdk directly for now.
Hooks
Use the hooks when you want to keep your own UI but still skip the wallet/transaction/API plumbing. All hooks must be called from a descendant of <RecurProvider>.
Every action hook returns the same shape:
Every query hook returns:
useRecur()
Access the configured RecurClient, current cluster, and connection state.
useAuth()
Manage the Recur JWT for the connected wallet. The provider auto-loads cached sessions from sessionStorage; this hook exposes manual sign-in and ensureAuthenticated() (returns a fresh JWT, signing in if needed).
useSubscribe()
Internally: client.getPlan → client.subscribe(wallet, options, token) (build → sign → confirm → register).
useMySubscriptions()
Returns the connected subscriber's subscriptions; auto-fetches on wallet/auth change.
usePlan(appId, planId) / usePlans(appId)
Read-only plan lookups. No auth required.
useCancelSubscription()
"request" (default) → request_cancel (prepaid time honored).
"instant" → subscriber_cancel (immediate close, prepaid time forfeited).
useReapprove()
Re-runs the SPL Token approve so the keeper can keep pulling. Use this when delegation is exhausted (after cycles payments) or if the subscriber manually revoked it.