Skip to main content

useSubscription

SolvaPay SDK


SolvaPay SDK / react/src / useSubscription

Function: useSubscription()

useSubscription(): SubscriptionStatus & object

Defined in: packages/react/src/hooks/useSubscription.ts:45

Hook to get current subscription status and information.

Returns the current user's subscription status, including active subscriptions, plan details, and payment information. Automatically syncs with the SolvaPay backend and handles loading and error states.

Returns

SubscriptionStatus & object

Subscription data and status

Example

import { useSubscription } from '@solvapay/react';

function Dashboard() {
const { subscriptions, hasPaidSubscription, isLoading, refetch } = useSubscription();

if (isLoading) return <Spinner />;

if (!hasPaidSubscription) {
return <UpgradePrompt />;
}

return (
<div>
<h2>Welcome, Premium User!</h2>
<p>Active subscriptions: {subscriptions.length}</p>
<button onClick={() => refetch()}>Refresh</button>
</div>
);
}

See

Since

1.0.0