mirror of
https://github.com/fergalmoran/supanextail.git
synced 2025-12-22 09:17:54 +00:00
15 lines
382 B
TypeScript
15 lines
382 B
TypeScript
/**
|
|
* This is a singleton to ensure we only instantiate Stripe once.
|
|
*/
|
|
import { Stripe, loadStripe } from '@stripe/stripe-js';
|
|
|
|
let stripePromise: Promise<Stripe | null>;
|
|
const getStripe = (): Promise<Stripe | null> => {
|
|
if (!stripePromise) {
|
|
stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY || '');
|
|
}
|
|
return stripePromise;
|
|
};
|
|
|
|
export default getStripe;
|