Getting started
Set up Lumen in 5 minutes
Onboarding
Go to https://getlumen.dev/login to get started. You will be directed to an onboarding page
Create your first Plan
You will be automatically redirected here after onboarding, but you can also visit https://getlumen.dev/plans/create
Integrate the PricingTable component
Installation
First, install the required packages:
npm install @getlumen/react @getlumen/server
We recommend using our shadcn component so you can easily customize the styling manually or by prompting cursor:
npx shadcn@latest add https://getlumen.dev/pricing-table.json
Frontend Integration
Import the PricingTable component and add it to your NextJS pricing page:
import { PricingTable } from "@/components/ui/pricing-table";
// OR if you don't want to use shadcn
// import { PricingTable } from '@getlumen/react'
export default function PricingPage() {
return (
<PricingTable
lumenPublishableKey={process.env.NEXT_PUBLIC_LUMEN_PUBLISHABLE_KEY}
userId={session?.user?.id}
loginRedirectUrl="/login"
/>
);
}
Required Props
lumenPublishableKey
: Your Lumen publishable key from the environment variablesuserId
: The ID of the currently logged-in userloginRedirectUrl
: Clicking subscribe will redirect to this url if userId is null/undefined
Implement feature access in your backend (optional)
To control access to features and track usage, use the server-side functions provided by @getlumen/server
:
import { sendEvent, isFeatureEntitled } from "@getlumen/server";
export async function POST(request: NextRequest) {
const supabase = await createClient();
const {
data: { user },
} = await supabase.auth.getUser();
if (
// Check if user still has credits
await isFeatureEntitled({
feature: "ai-chat-requests",
userId: user.id,
})
) {
// Do backend logic here ...
// after completion you can record usage with:
sendEvent({
name: "ai-chat-requests",
userId: user.id,
});
}
}
Integrate Stripe
If you didn't set your Stripe keys during onboarding, now it the time to set them up https://getlumen.dev/developer/stripe
Done!
Lumen billing is ready, your users can now subscribe to your SaaS!