- Next.js
- React
- Server
- Express
Installation
Requirements
- React 18 or 19
- Next.js 14 or 15
Quick Start
1. Set Up Environment Variables
Add your Flowglad API key to your environment:.env
2. Create Server Client
Create a Flowglad server factory function in a shared file, eg.utils/flowglad.ts:Important:
B2B apps: Pass
customerExternalId is the ID from your app’s database (e.g., user.id or organization.id), not Flowglad’s customer ID.B2C apps: Pass user.id as customerExternalIdB2B apps: Pass
organization.id or team.id as customerExternalIdFlowglad integrates seamlessly with your auth provider. Read more about auth options here.
3. Create API Route Handler
Flowglad integrates seamlessly with your auth provider. Read more about auth options here.
4. Wrap Your App with FlowgladProvider
5. Use the Billing Hook
Read more about the Flowglad Next.js SDK at the Next.js documentation page