{"_id":"@botparty/checkout-nextjs","_rev":"4-1a5ce1e6b04f9eb38d64f07c7fed359e","name":"@botparty/checkout-nextjs","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.2":{"name":"@botparty/checkout-nextjs","version":"0.0.2","keywords":["botparty","checkout","stripe","nextjs","react","campaigns"],"license":"MIT","_id":"@botparty/checkout-nextjs@0.0.2","maintainers":[{"name":"smarcombes","email":"severin-m@rcombes.fr"}],"dist":{"shasum":"3ea254b8aaeccc83a10d9f22359d4dd13db1ea40","tarball":"https://registry.npmjs.org/@botparty/checkout-nextjs/-/checkout-nextjs-0.0.2.tgz","fileCount":16,"integrity":"sha512-GQweOIVsbB9td2AuCp9zRJdXONXEYXK+RhdhNpumICujCOBMSjGb9EfvaAPwIptwsMlyB/pIN31puF4dsgKJww==","signatures":[{"sig":"MEUCIQDRY1erIv6x+2zaIaLLOc+Bf+mVJEMgR/16bTUG0nSrLgIgYZKEGIn2vhMX9FrfOCi/pa6dVSg4157tZ93GyPknES4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":74121},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./client":{"import":{"types":"./dist/client/index.d.ts","default":"./dist/client/index.js"},"require":{"types":"./dist/client/index.d.cts","default":"./dist/client/index.cjs"}},"./server":{"import":{"types":"./dist/server/index.d.ts","default":"./dist/server/index.js"},"require":{"types":"./dist/server/index.d.cts","default":"./dist/server/index.cjs"}}},"gitHead":"ca33f1eacf044cbf4ebed39a74c35a29c70a54dc","scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","deploy":"npm version patch && npm publish","type-check":"tsc --noEmit","prepublishOnly":"pnpm run clean && pnpm run build"},"_npmUser":{"name":"smarcombes","email":"severin-m@rcombes.fr"},"_npmVersion":"10.9.2","description":"NextAuth-style Next.js SDK for the BotParty checkout service: catch-all App Router handler + React provider, hooks, and gate components.","directories":{},"sideEffects":false,"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.1.0","tsup":"^8.0.0","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.7.0","@types/node":"^22.0.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0"},"peerDependencies":{"next":">=15.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/checkout-nextjs_0.0.2_1779455170658_0.01404947969743331","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@botparty/checkout-nextjs","version":"0.0.3","keywords":["botparty","checkout","stripe","nextjs","react","campaigns"],"license":"MIT","_id":"@botparty/checkout-nextjs@0.0.3","maintainers":[{"name":"smarcombes","email":"severin-m@rcombes.fr"}],"dist":{"shasum":"c51ba89a9ef7d740c0b46789a7992285cc3cc7a0","tarball":"https://registry.npmjs.org/@botparty/checkout-nextjs/-/checkout-nextjs-0.0.3.tgz","fileCount":16,"integrity":"sha512-YD/HphIW5aHwh0uoBZN+JUscGbsCip6A7qeNQeXDNY/lHwKlKwm4VKnZznCZykBvtB+x4Y17ZAd+5ASd6mjyog==","signatures":[{"sig":"MEUCIQCwNxjgz4jl1pMGBjm/wXA6bXwThmDWhjLNeKSx270bHQIgLai/Fp/RbzrO3ozyjRwDio5au3HEWdExFLs9TeSEIkk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":74497},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./client":{"import":{"types":"./dist/client/index.d.ts","default":"./dist/client/index.js"},"require":{"types":"./dist/client/index.d.cts","default":"./dist/client/index.cjs"}},"./server":{"import":{"types":"./dist/server/index.d.ts","default":"./dist/server/index.js"},"require":{"types":"./dist/server/index.d.cts","default":"./dist/server/index.cjs"}}},"gitHead":"fbb2857225529fb313d1aac62f0f70c0f23da6ed","scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","deploy":"npm version patch && npm publish","type-check":"tsc --noEmit","prepublishOnly":"pnpm run clean && pnpm run build"},"_npmUser":{"name":"smarcombes","email":"severin-m@rcombes.fr"},"_npmVersion":"10.9.2","description":"NextAuth-style Next.js SDK for the BotParty checkout service: catch-all App Router handler + React provider, hooks, and gate components.","directories":{},"sideEffects":false,"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.1.0","tsup":"^8.0.0","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.7.0","@types/node":"^22.0.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0"},"peerDependencies":{"next":">=15.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/checkout-nextjs_0.0.3_1780420598807_0.04726173012529089","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@botparty/checkout-nextjs","version":"0.0.4","keywords":["botparty","checkout","stripe","nextjs","react","campaigns"],"license":"MIT","_id":"@botparty/checkout-nextjs@0.0.4","maintainers":[{"name":"smarcombes","email":"severin-m@rcombes.fr"}],"dist":{"shasum":"c2c9452107f3b65f6714090ea1a6fa89d9470ea1","tarball":"https://registry.npmjs.org/@botparty/checkout-nextjs/-/checkout-nextjs-0.0.4.tgz","fileCount":16,"integrity":"sha512-xV+Y6lh8VxSE3TyoEQ9aCEvR3yMarucUuz4G3+24/MTUCQtm3BjkCDLI5GtwcSHbJNv1ZYCcZ42jPqv+zBXP3w==","signatures":[{"sig":"MEUCIQC2h1k6tz7fEI7Ep2E7LPKFepR6haKBEtqlJj+j2WqAAQIgGxT11McUffMsmcwm/v9Fo4cV/aZj5EbpfkuBCAEeeTY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":75309},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./client":{"import":{"types":"./dist/client/index.d.ts","default":"./dist/client/index.js"},"require":{"types":"./dist/client/index.d.cts","default":"./dist/client/index.cjs"}},"./server":{"import":{"types":"./dist/server/index.d.ts","default":"./dist/server/index.js"},"require":{"types":"./dist/server/index.d.cts","default":"./dist/server/index.cjs"}}},"gitHead":"fbb2857225529fb313d1aac62f0f70c0f23da6ed","scripts":{"dev":"tsup --watch","build":"tsup","clean":"rm -rf dist","deploy":"npm version patch && npm publish","type-check":"tsc --noEmit","prepublishOnly":"pnpm run clean && pnpm run build"},"_npmUser":{"name":"smarcombes","email":"severin-m@rcombes.fr"},"_npmVersion":"11.9.0","description":"NextAuth-style Next.js SDK for the BotParty checkout service: catch-all App Router handler + React provider, hooks, and gate components.","directories":{},"sideEffects":false,"_nodeVersion":"25.6.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"next":"^15.1.0","tsup":"^8.0.0","react":"^19.0.0","react-dom":"^19.0.0","typescript":"^5.7.0","@types/node":"^22.0.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0"},"peerDependencies":{"next":">=15.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/checkout-nextjs_0.0.4_1780488645749_0.5202551213700604","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@botparty/checkout-nextjs","version":"0.0.5","description":"NextAuth-style Next.js SDK for the BotParty checkout service: catch-all App Router handler + React provider, hooks, and gate components.","type":"module","exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./server":{"import":{"types":"./dist/server/index.d.ts","default":"./dist/server/index.js"},"require":{"types":"./dist/server/index.d.cts","default":"./dist/server/index.cjs"}},"./client":{"import":{"types":"./dist/client/index.d.ts","default":"./dist/client/index.js"},"require":{"types":"./dist/client/index.d.cts","default":"./dist/client/index.cjs"}}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","sideEffects":false,"publishConfig":{"access":"public"},"scripts":{"clean":"rm -rf dist","build":"tsup","dev":"tsup --watch","type-check":"tsc --noEmit","prepublishOnly":"pnpm run clean && pnpm run build","deploy":"npm version patch && npm publish"},"peerDependencies":{"next":">=15.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"devDependencies":{"@types/node":"^22.0.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0","next":"^15.1.0","react":"^19.0.0","react-dom":"^19.0.0","tsup":"^8.0.0","typescript":"^5.7.0"},"keywords":["botparty","checkout","stripe","nextjs","react","campaigns"],"license":"MIT","_id":"@botparty/checkout-nextjs@0.0.5","gitHead":"12f91f05664acda04feca3c2379722d27c440b84","_nodeVersion":"23.10.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-hHGUaml7tHvhwsZreuBZCR6o95RzmgssMs1aLuT4qXFcrljFNLs7fVG/H9cUuvfbkvnLmclIqeBbIhN5ygA1GA==","shasum":"840df957241dd1c5f8b11c9d5fbe3ae464866650","tarball":"https://registry.npmjs.org/@botparty/checkout-nextjs/-/checkout-nextjs-0.0.5.tgz","fileCount":16,"unpackedSize":71233,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDuBqjhkLZc/dd4YsX81R2f0NmeIZloI55NEVlV9gKgwgIgVMeWt1WsYgQU4n9EJQ2oLqsWJdRfV9UyCYEA2JrNKm0="}]},"_npmUser":{"name":"smarcombes","email":"severin-m@rcombes.fr"},"directories":{},"maintainers":[{"name":"smarcombes","email":"severin-m@rcombes.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/checkout-nextjs_0.0.5_1780652242199_0.5149422741413161"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-22T13:06:10.121Z","modified":"2026-06-05T09:37:22.447Z","0.0.2":"2026-05-22T13:06:10.823Z","0.0.3":"2026-06-02T17:16:38.965Z","0.0.4":"2026-06-03T12:10:45.880Z","0.0.5":"2026-06-05T09:37:22.340Z"},"license":"MIT","keywords":["botparty","checkout","stripe","nextjs","react","campaigns"],"description":"NextAuth-style Next.js SDK for the BotParty checkout service: catch-all App Router handler + React provider, hooks, and gate components.","maintainers":[{"name":"smarcombes","email":"severin-m@rcombes.fr"}],"readme":"# @botparty/checkout-nextjs\n\nNextAuth-style Next.js SDK for the BotParty `checkout` service.\n\n```bash\npnpm add @botparty/checkout-nextjs\n```\n\n## What you get\n\n- A single `defineCheckout({...})` factory that drives both the server route\n  handler and the React client.\n- A catch-all App Router handler — drop it at\n  `app/api/checkout/[...checkout]/route.ts` and you're done.\n- A `<CheckoutProvider>`, hooks (`usePurchaseStatus`, `useLedger`,\n  `useInvoices`, `useStartPurchase`), gates (`<HasPurchased>`,\n  `<HasNotPurchased>`, `<PurchaseGate>`), and headless components\n  (`<PurchaseButton>`, `<Ledger>`, `<Invoices>`).\n- Automatic campaign attribution via the BotParty `campaigns` service when\n  `botpartyMiddleware` is installed (or via a `_mcmpid` cookie/query as a\n  fallback).\n\n## 60-second setup\n\n`src/lib/checkout.ts` — the source of truth:\n\n```ts\nimport { defineCheckout } from \"@botparty/checkout-nextjs/server\";\nimport { auth } from \"@botparty/nextjs/server\";\n\nexport const checkoutConfig = defineCheckout({\n  apiToken: process.env.CHECKOUT_API_TOKEN!,\n  async getUser() {\n    const s = await auth();\n    return s.isAuthenticated ? { id: s.userId!, email: s.email } : null;\n  },\n  async getCampaignShortId() {\n    const s = await auth();\n    return (s as any).meta?.cmpid ?? null;\n  },\n  successUrl: \"/thank-you\",\n  cancelUrl: \"/pricing\",\n  products: [\n    { slug: \"lifetime\",   title: \"Lifetime\",   amountInCents: 4999, type: \"one-time\", maxPerUser: 1 },\n    { slug: \"credits-10\", title: \"10 Credits\", amountInCents:  999, type: \"one-time\" },\n    { slug: \"pro-plan\",   title: \"Pro\",        amountInCents: 1999, type: \"subscription\", period: \"monthly\" },\n  ],\n});\n```\n\n`src/app/api/checkout/[...checkout]/route.ts` — the catch-all handler:\n\n```ts\nimport { createCheckoutHandler } from \"@botparty/checkout-nextjs/server\";\nimport { checkoutConfig } from \"@/lib/checkout\";\n\nconst handler = createCheckoutHandler(checkoutConfig);\nexport const GET = handler.GET;\nexport const POST = handler.POST;\n```\n\n`src/app/layout.tsx` — wrap the tree:\n\n```tsx\nimport { CheckoutProvider } from \"@botparty/checkout-nextjs/client\";\n\nexport default function Layout({ children }) {\n  return (\n    <html><body>\n      <CheckoutProvider basePath=\"/api/checkout\">{children}</CheckoutProvider>\n    </body></html>\n  );\n}\n```\n\n`src/app/pricing/page.tsx`:\n\n```tsx\n\"use client\";\nimport { PurchaseButton, HasPurchased } from \"@botparty/checkout-nextjs/client\";\n\nexport default function Pricing() {\n  return (\n    <>\n      <PurchaseButton productId=\"lifetime\" redirectUrl=\"/thank-you\">Buy lifetime</PurchaseButton>\n      <PurchaseButton productId=\"pro-plan\" redirectUrl=\"/thank-you\">Subscribe</PurchaseButton>\n      <HasPurchased productId=\"lifetime\">\n        <p>Welcome back, lifetime member 👋</p>\n      </HasPurchased>\n    </>\n  );\n}\n```\n\n## Routes mounted by `createCheckoutHandler`\n\nAll paths are relative to `basePath` (default `/api/checkout`):\n\n| Method | Path                       | Description                                              |\n| ------ | -------------------------- | -------------------------------------------------------- |\n| GET    | `/products`                | Returns the static catalog (or live from `apps/checkout`) |\n| GET    | `/:slug`                   | Single product info                                       |\n| GET    | `/:slug/purchase?...`      | Starts upsell/hosted Stripe Checkout, 302s away          |\n| GET    | `/:slug/status`            | `{ hasPurchased, purchase? }` for the current user       |\n| GET    | `/ledger`                  | Current user's purchase ledger                            |\n| GET    | `/invoices`                | Current user's invoices                                   |\n| POST   | `/sync`                    | Force product sync into `apps/checkout`                  |\n\nThe `/:slug/purchase` route reads `_mcmpid` (via `getCampaignShortId`,\n`_mcmpid` cookie, or `?_mcmpid=` query) and forwards it to `apps/checkout` as\n`campaignShortId`, so attribution survives the Stripe round-trip.\n\n## Imports map\n\n- `@botparty/checkout-nextjs/server` — `defineCheckout`, `createCheckoutHandler`,\n  fetch helpers (`createLink`, `upsell`, `hasPurchased`, `listLedger`, …).\n- `@botparty/checkout-nextjs/client` — `<CheckoutProvider>`, hooks, gates,\n  buttons, ledger components.\n- `@botparty/checkout-nextjs` — re-exports the server entry. Don't import this\n  from a client component; use `/client` instead so React isn't pulled into\n  your server bundle.\n\nSee [`templates/nextjs`](../../templates/nextjs) for a full working example.\n","readmeFilename":"README.md"}