bbuddy-ui/src/utils/get-stripe.ts

12 lines
332 B
TypeScript

import { Stripe, loadStripe } from '@stripe/stripe-js';
let stripePromise: Promise<Stripe | null>;
export default function getStripe(): Promise<Stripe | null> {
if (!stripePromise)
stripePromise = loadStripe(
process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY as string,
);
return stripePromise;
}