@creem_io/nextjs

中文文档
0.6.4发布于 2026/09/18MITTypeScriptESM + CJS构建来源已验证近 30 天下载 9795

Creem payment integration for Next.js applications

原始使用文档
文档目录5 节
  1. Install
  2. Minimal setup
  3. Exports
  4. Example and development
  5. License

@creem_io/nextjs

Checkout, customer portal, and verified webhook helpers for the Next.js App Router.

Full documentation: docs.creem.io/code/sdks/nextjs

Install

pnpm add @creem_io/nextjs

Requires Next.js 13 or newer and React 18 or newer.

Minimal setup

Create a checkout route:

// app/checkout/route.ts
import { Checkout } from "@creem_io/nextjs";

export const GET = Checkout({
  apiKey: process.env.CREEM_API_KEY!,
  testMode: true,
  defaultSuccessUrl: "/billing/success",
});

Render a checkout link:

import { CreemCheckout } from "@creem_io/nextjs";

export default function PricingPage() {
  return <CreemCheckout productId="prod_...">Subscribe</CreemCheckout>;
}

Handle webhooks:

// app/api/webhook/creem/route.ts
import { Webhook } from "@creem_io/nextjs";

export const POST = Webhook({
  webhookSecret: process.env.CREEM_WEBHOOK_SECRET!,
  onCheckoutCompleted: async ({ customer, product }) => {
    console.log(`${customer.email} purchased ${product.name}`);
  },
});

Callbacks must be idempotent because webhook deliveries can be retried. Granting or revoking application access requires a trusted user ID; follow the authenticated checkout pattern in the full guide before using the access callbacks.

Exports

ExportPurpose
CreemCheckoutBuilds a link to your checkout route.
CreemPortalBuilds a link to your customer portal route.
CheckoutCreates checkout sessions and redirects to Creem.
PortalCreates customer billing links and redirects to the portal.
WebhookVerifies and dispatches Creem webhook events.

See the Next.js adapter guide for all props, route setup, access callbacks, and security guidance. See Common gotchas for webhook field names, timestamps, checkout amounts, and metadata.

Example and development

From the repository root:

pnpm --filter @creem_io/nextjs build
pnpm --filter @creem_io/nextjs typecheck
pnpm --filter @creem_io/nextjs check:package

License

MIT

版本与发布记录

@creem_io/nextjs 共发布 14 个版本,首次发布于 2025/11/18;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.4latest2026/09/181 个月前
0.6.32026/09/171 个月前
0.6.22026/09/161 个月前
0.6.12026/09/161 个月前
0.5.72026/09/092 个月前
0.5.62026/09/042 个月前

关于 @creem_io/nextjs 的常见问题

@creem_io/nextjs 是什么?

Creem payment integration for Next.js applications

如何安装 @creem_io/nextjs?

在项目目录运行 npm install @creem_io/nextjs,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:next(>=13.0.0)、react(>=18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@creem_io/nextjs 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@creem_io/nextjs 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@creem_io/nextjs 可以商用吗?

@creem_io/nextjs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@creem_io/nextjs 的下载量有多少?

根据 npm 官方下载统计,@creem_io/nextjs 在 2026/10/11 – 2026/11/09 这 30 天内被下载 9,795 次,日均约 327 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@creem_io/nextjs 还在维护吗?

最新版本 0.6.4 发布于 2026/09/18(1 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 14 个;首次发布于 2025/11/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。