Skip to main content

useSolvaPay

SolvaPay SDK


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

SolvaPayContextValue

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

Since

1.0.0