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 devOpens 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| Variable | Scope | Where to Find |
|---|---|---|
KEYMINT_ADMIN_API_KEY | Server | Dashboard → Developer → API Keys (admin scope) |
KEYMINT_CLIENT_API_KEY | Server | Dashboard → Developer → API Keys (client scope) |
KEYMINT_PRODUCT_ID | Server | Dashboard → Products |
KEYMINT_WEBHOOK_SECRET | Server | Dashboard → 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 wrapperAPI Methods Used
| Function | Where | Scope | Purpose |
|---|---|---|---|
createCustomerLicense() | license-service.ts | admin | Create a license with customer details |
blockLicense() | license-service.ts | admin | Block a license key |
unblockLicense() | license-service.ts | admin | Unblock a license key |
getLicenseInfo() | license-service.ts | admin | Query license details |
validateLicense() | license-service.ts | client | Validate/activate a license |
Deploy
bash
npm run build
# Deploy to Vercel, Railway, or any Node.js hostSet 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