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 purchase data, payment methods, and customer information.
Other hooks like usePurchase 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 { purchase, createPayment, processPayment } = useSolvaPay();
const handlePayment = async () => {
const intent = await createPayment({
planRef: 'pln_premium',
productRef: 'prd_myapi'
});
// Process payment...
};
return <div>Purchase status: {purchase.hasPaidPurchase ? 'Active' : 'None'}</div>;
}
Throws
If used outside of SolvaPayProvider
See
- SolvaPayProvider for required context provider
- usePurchase for purchase-specific hook
- useCheckout for checkout-specific hook
Since
1.0.0