Philosophy
Why we built Lumen and best practices
Problem
Most developers implement Stripe with plan-based checks scattered throughout their codebase:
if (plan === "gold") {
// give access to feature A
}
if (plan === "gold" || plan === "enterprise") {
// give access to advanced analytics
// also give access to feature B
}
Consider this scenario: Your Chief Revenue Officer discovers that "advanced analytics" drives conversions and wants to move it to the free plan with a 7 day trial period. Now engineers must find and update every related conditional without breaking existing functionality, with the added complexity of figuring out how to implement this free trial feature.
Solution
Lumen eliminates plan-based logic by focusing on features instead of plans:
if (
await isFeatureEntitled({ feature: "advanced-analytics", userId: user.id })
) {
// give access
}
Structuring your code like this makes it trivial to edit or introduce new plans via the Lumen Dashboard. Your CRO can now add the "advanced-analytics" feature to the free plan with a free trial option and everything just works!