Openstatus
www.openstatus.dev
1import type { Stripe as StripeProps } from "@stripe/stripe-js";
2import { loadStripe } from "@stripe/stripe-js";
3
4let stripePromise: Promise<StripeProps | null>;
5
6export const getStripe = () => {
7 if (!process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY) {
8 throw new Error("NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY is not set");
9 }
10
11 if (!stripePromise) {
12 stripePromise = loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY);
13 }
14
15 return stripePromise;
16};