Next.js SaaS License Starter

Clone-and-run Next.js app with Keymint license management pre-configured. License dashboard, API routes, and webhook handling included.

Quick Start

bash
git clone https://github.com/keymint-dev/keymint-nextjs-starter.git
cd keymint-nextjs-starter
npm install
cp .env.example .env.local
npm run dev

Opens a Next.js app at localhost:3000 with a license management dashboard. Create products, issue keys, and monitor activations.

What's Included

  • License dashboard — Starter dashboard page with setup instructions
  • Key generation — API route for creating license keys with customer details
  • Webhook receiver — Verified Keymint outbound webhook handler with HMAC-SHA256 signature verification
  • License service — Server-side wrapper for create, block, unblock, query, and validate operations

Configuration

bash
KEYMINT_ADMIN_API_KEY=km_admin_your_key
KEYMINT_CLIENT_API_KEY=km_client_your_key
KEYMINT_PRODUCT_ID=prod_Nx8K2mLpQ4rVtW9sBc
KEYMINT_WEBHOOK_SECRET=whsec_your_signing_secret
VariableScopeWhere to Find
KEYMINT_ADMIN_API_KEYServerDashboard → Developer → API Keys (admin scope)
KEYMINT_CLIENT_API_KEYServerDashboard → Developer → API Keys (client scope)
KEYMINT_PRODUCT_IDServerDashboard → Products
KEYMINT_WEBHOOK_SECRETServerDashboard → Developer → Webhooks → your endpoint

Project Structure

text
src/
├── app/
│   ├── page.tsx                        # Landing page
│   ├── layout.tsx                      # Root layout
│   ├── api/
│   │   ├── licenses/route.ts           # License creation endpoint
│   │   └── webhooks/keymint/route.ts   # Keymint webhook receiver
│   └── dashboard/
│       └── licenses/page.tsx           # License management UI
└── lib/
    └── license-service.ts              # Keymint API wrapper

API Methods Used

FunctionWhereScopePurpose
createCustomerLicense()license-service.tsadminCreate a license with customer details
blockLicense()license-service.tsadminBlock a license key
unblockLicense()license-service.tsadminUnblock a license key
getLicenseInfo()license-service.tsadminQuery license details
validateLicense()license-service.tsclientValidate/activate a license

Deploy

bash
npm run build
# Deploy to Vercel, Railway, or any Node.js host

Set the KEYMINT_WEBHOOK_SECRET as the signing secret for your Keymint webhook endpoint. The URL should be https://yourdomain.com/api/webhooks/keymint.

Next Steps

  • Add Stripe subscription licensing for automated key provisioning
  • Add a database (Drizzle, Prisma) to persist license and customer records
  • Add customer self-service portal for license management
  • Configure Keymint webhooks to point to /api/webhooks/keymint