Overview
This page provides complete examples and common integration patterns for Flowglad SDKs. For full working applications, check out our example projects.Example Projects
Generation-based Subscription
A Next.js app with authentication and billing integration, demonstrating a pricing model with subscription, single-payment, and usage. Location: examples/generation-based-subscription Features:- Next.js App Router
- BetterAuth authentication
- FlowgladProvider setup
- Pricing table
- Feature-gated content
- Usage-based billing for image generation
- Subscription management
pricing.yaml- Pricing model specificationsrc/lib/flowglad.ts- Flowglad server setupsrc/app/layout.tsx- FlowgladProvider setupsrc/app/api/flowglad/[...path]/route.ts- Flowglad routeHandlersrc/app/api/usage-events/route.ts- Route for usage event creationsrc/components/pricing-cards-grid.tsx- Pricing page with usePricing
Tiered Usage-Gated Subscription
A Next.js app demonstrating tiered subscription plans with usage limits and feature access by tier. Similar to ChatGPT’s pricing model, with different quotas, context windows, and capabilities varying by plan level. Location: examples/tiered-usage-gated-subscription Features:- Next.js App Router
- Tiered subscription plans with usage gates
- Feature access by subscription tier
- Usage credit grants that renew monthly
- Multiple usage meters with tiered limits
- Individual to multi-seat plan support
pricing.yaml- Pricing model with tiered usage limitssrc/lib/flowglad.ts- Flowglad server setupsrc/app/layout.tsx- FlowgladProvider setupsrc/app/api/flowglad/[...path]/route.ts- Flowglad routeHandler- Usage balance checking and tier-based feature gating
Usage Limit Subscription
A Next.js app demonstrating a hybrid subscription + usage model. Subscriptions include monthly usage credits that renew each billing period, with optional overage billing. Perfect for API-intensive products like Cursor. Location: examples/usage-limit-subscription Features:- Next.js App Router
- Hybrid subscription + metered usage model
- Monthly usage credits that renew automatically
- Optional on-demand credit purchases
- Overage billing when credits are exhausted
- Multiple tiered plans with different usage limits
pricing.yaml- Pricing model with usage limits and overagesrc/lib/flowglad.ts- Flowglad server setupsrc/app/layout.tsx- FlowgladProvider setupsrc/app/api/flowglad/[...path]/route.ts- Flowglad routeHandler- Usage balance tracking and overage handling
Complete Integration Examples
Next.js Setup
Full setup for a Next.js application:React SPA with Node.js Backend
Setup for a React application with a separate Node.js backend:Common Patterns
Feature Gating
Usage Metering
Subscription Management
Pricing Table
Customer Portal
Testing Examples
Mock Billing Context
Next Steps
Next.js SDK
Get started with Next.js
Server SDK
Explore server capabilities
Quickstart
Follow the quickstart guide
API Reference
Browse the API documentation