Files
supanextail/utils/stripe.js
2021-08-10 12:50:47 +02:00

15 lines
332 B
JavaScript

/**
* This is a singleton to ensure we only instantiate Stripe once.
*/
import { loadStripe } from '@stripe/stripe-js';
let stripePromise = null;
const getStripe = () => {
if (!stripePromise) {
stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY);
}
return stripePromise;
};
export default getStripe;