Customer Portal
Self-service portal for customers to manage their subscriptions.
Self-service page where customers manage their subscription, view usage, change plans, and purchase credits. Automatically created with every subscription.
What customers can do
- View current subscription and billing cycle
- See usage across all features
- Upgrade or downgrade plans (requires a Plan Group)
- Purchase Credit Packs, balance top-ups, and Add-ons
- Update payment method and billing details
- View invoice history
- Cancel subscription
Purchases are available on active, trialing, and free plan subscriptions. Free plan customers are prompted to add a payment method on their first purchase.
Generate a portal URL
Portal URLs are single-use and expire after 2 hours of inactivity. Generate a fresh URL on each request.
const portal = await commet.portal.getUrl({ customerId: 'user_123' })
redirect(portal.data.portalUrl)You can identify customers by customerId (Commet ID or your external ID) or email.
Next.js helper
@commet/next provides a one-line route handler that generates portal URLs and redirects automatically.
import { CustomerPortal } from '@commet/next'
export const GET = CustomerPortal({
apiKey: process.env.COMMET_API_KEY!,
getCustomerId: async (req) => {
return 'user_123'
},
})<a href="/api/commet/portal">Manage Billing</a>Related
How is this guide?