import { initializePaddle, type Paddle } from "@paddle/paddle-js"; let cached: Promise | null = null; /* One Paddle instance for the app. The token and environment are baked into the * build (NEXT_PUBLIC_*), never fetched, so a production build can never load a * sandbox token by accident. */ export function initPaddle(): Promise { if (!cached) { cached = initializePaddle({ environment: (process.env.NEXT_PUBLIC_PADDLE_ENV as "sandbox" | "production") ?? "sandbox", token: process.env.NEXT_PUBLIC_PADDLE_CLIENT_TOKEN ?? "", }); } return cached; }