useSolvaPay
SolvaPay SDK / react/src / useSolvaPay
Function: useSolvaPay()
useSolvaPay():
SolvaPayContextValue
Defined in: packages/react/src/hooks/useSolvaPay.ts:46
Hook to access SolvaPay context and provider methods.
This is the base hook that provides access to all SolvaPay functionality
including subscription data, payment methods, and customer information.
Other hooks like useSubscription and useCheckout use this internally.
Must be used within a SolvaPayProvider component.
Returns
SolvaPay context value with all provider methods and state
Example
import { useSolvaPay } from '@solvapay/react';
function CustomComponent() {
const { subscription, createPayment, processPayment } = useSolvaPay();
const handlePayment = async () => {
const intent = await createPayment({
planRef: 'pln_premium',
agentRef: 'agt_myapi'
});
// Process payment...
};
return <div>Subscription status: {subscription.hasPaidSubscription ? 'Active' : 'None'}</div>;
}
Throws
If used outside of SolvaPayProvider
See
- SolvaPayProvider for required context provider
- useSubscription for subscription-specific hook
- useCheckout for checkout-specific hook
Since
1.0.0