Skip to main content

Requirements

  • Node.js 18+ (or any edge runtime with Web Crypto API)
  • TypeScript 5.0+ (optional but recommended)

Install

Set your API key

Add your key to your environment:
.env
Use ck_test_ keys in development and CI. Test keys are completely isolated from production data.

Basic setup

Next.js setup

Create a shared client file so you don’t instantiate on every request:
lib/churnkit.ts
Then import churn in your Server Actions, Route Handlers, or API routes:
app/api/checkout/route.ts

Cloudflare Workers / Edge

The SDK uses only Web-standard APIs (fetch, crypto.subtle) and works on Cloudflare Workers, Vercel Edge Functions, and Deno Deploy with no modifications:
worker.ts

Module formats

The package ships both ESM and CJS: import and require both work out of the box.