@paykit-sdk/react
v1.1.96
Published
React hooks and components for PayKit SDK - Universal payment processing with Stripe, Polar, and more
Maintainers
Readme
@paykit-sdk/react
PayKit React is a toolkit designed to simplify payment processing in React applications. It provides hooks and components that work seamlessly with any PayKit provider (Stripe, Polar, Gumroad, etc.) to handle customers, subscriptions, and checkouts.
Installation
npm install @paykit-sdk/reactQuick Start
1. Setup PayKit
import { PayKit } from '@paykit-sdk/core';
import { paypal } from '@paykit-sdk/paypal';
const provider = paypal();
const paykit = new PayKit(provider);
export { provider, paykit };2. Setup Provider
import { provider } from '@lib/paykit';
import { PaykitProvider } from '@paykit-sdk/react';
function App() {
return (
<PaykitProvider provider={provider}>
<YourApp />
</PaykitProvider>
);
}3. Use Hooks
import * as React from 'react';
import { useCustomer, useSubscription, useCheckout } from '@paykit-sdk/react';
import { CustomerView } from './customer-view';
const CustomerDashboard = ({ customerId }: { customerId: string }) => {
const { retrieve, create, update } = useCustomer();
React.useEffect(() => {
retrieve.run(customerId);
}, [customerId]);
if (retrieve.loading) return <Spinner />;
if (retrieve.error) return <Error error={retrieve.error} />;
return <CustomerView customer={retrieve.data} />;
};Available Hooks
useCustomer()- Manage customer datauseSubscription()- Handle subscriptionsuseCheckout()- Process checkouts
Providers
Works with any PayKit provider including Stripe, Polar, Gumroad, and more.
Documentation
TypeScript Support
Full TypeScript support included.
License
MIT
