Environment variables
The Unchurn widget needs two environment variables on your server. There are no browser-facing or build-time variables — you don’t add anything to your Vite or Next.js bundle config.
| Variable | Required | Description |
|---|---|---|
UNCHURN_SECRET | yes | HMAC signing key. Get it from your Unchurn dashboard. Rotate it from the dashboard if you suspect a leak. |
UNCHURN_MERCHANT_ID | yes | Your merchant identifier from the Unchurn dashboard. |
Both are server-only. The React hook (useUnchurn) only calls your own tokenEndpoint, so these never reach the browser.
// app/api/unchurn/token/route.ts
import { createUnchurnHandler } from '@unchurn.dev/widget/nextjs';
export const POST = createUnchurnHandler({
secret: process.env.UNCHURN_SECRET!,
merchantId: process.env.UNCHURN_MERCHANT_ID!,
resolveUser: async (req) => { /* ... */ },
});Cross-links
Last updated on