Skip to main content

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

useSuccessPageFeatures

A hook that provides plan features with associated icons and colors for display on checkout success pages.

Source file: template/hooks/use-success-page-features.ts

Overview

useSuccessPageFeatures extends the base usePricingFeatures hook by mapping each plan feature to an appropriate Lucide icon and a Tailwind color class. This enables success pages to show users a visually rich summary of what their selected plan includes. The feature text is sourced directly from usePricingFeatures to ensure consistency with pricing pages.

Signature

function useSuccessPageFeatures(): {
getPlanFeaturesWithIcons: (planType: PaymentPlan) => SuccessPageFeature[];
}

Parameters

None. This hook takes no arguments.

Return Value

PropertyTypeDescription
getPlanFeaturesWithIcons(planType: PaymentPlan) => SuccessPageFeature[]Returns features for a plan with associated icons and colors

SuccessPageFeature Interface

interface SuccessPageFeature {
icon: any; // Lucide React icon component
text: string; // Feature description text (from usePricingFeatures)
color: string; // Tailwind CSS color class (e.g., "text-blue-400")
}

PaymentPlan Enum

enum PaymentPlan {
FREE = 'free',
STANDARD = 'standard',
PREMIUM = 'premium',
}

Implementation Details

Icon Mapping

Each plan has a predefined array of icon/color pairs, indexed positionally to match the features from usePricingFeatures:

Free Plan Icons:

IndexIconColor
0FileTexttext-blue-400
1ImageIcontext-green-400
2Globetext-purple-400
3-4Eyetext-orange-400
5Clocktext-gray-400
6-7Mailtext-red-400

Standard Plan Icons:

IndexIconColor
0-1FileTexttext-blue-400
2ImageIcontext-green-400
3Shieldtext-yellow-400
4Zaptext-purple-400
5Share2text-orange-400
6BarChart3text-pink-400
7Mailtext-red-400
8FileTexttext-cyan-400

Premium Plan Icons:

IndexIconColor
0-1TrendingUptext-yellow-400
2Startext-blue-400
3Shieldtext-green-400
4Videotext-purple-400
5ImageIcontext-orange-400
6Globetext-pink-400
7Mailtext-cyan-400
8BarChart3text-red-400
9Phonetext-indigo-400
10Zaptext-green-400

Any feature index beyond the predefined list falls back to FileText with text-gray-400.

Data Consistency

The hook uses the exact same feature text strings from usePricingFeatures.getFeaturesByPlan(). It only adds visual metadata (icon and color). This ensures that feature descriptions on the success page always match those on the pricing page.

Usage Examples

Success page feature list

import { useSuccessPageFeatures } from '@/hooks/use-success-page-features';
import { PaymentPlan } from '@/lib/constants';

function CheckoutSuccessPage({ plan }: { plan: PaymentPlan }) {
const { getPlanFeaturesWithIcons } = useSuccessPageFeatures();
const features = getPlanFeaturesWithIcons(plan);

return (
<div className="space-y-3">
<h2>Your plan includes:</h2>
{features.map((feature, index) => {
const Icon = feature.icon;
return (
<div key={index} className="flex items-center gap-2">
<Icon className={`h-5 w-5 ${feature.color}`} />
<span>{feature.text}</span>
</div>
);
})}
</div>
);
}

Conditional rendering by plan

function SuccessContent({ planType }: { planType: PaymentPlan }) {
const { getPlanFeaturesWithIcons } = useSuccessPageFeatures();
const features = getPlanFeaturesWithIcons(planType);

return (
<div>
<h3>
{planType === PaymentPlan.PREMIUM && 'Premium'}
{planType === PaymentPlan.STANDARD && 'Standard'}
{planType === PaymentPlan.FREE && 'Free'}
{' '}Plan Features
</h3>
<ul>
{features.map((feature, i) => {
const Icon = feature.icon;
return (
<li key={i} className="flex items-center gap-2 py-1">
<Icon className={`h-4 w-4 ${feature.color}`} />
<span className="text-sm">{feature.text}</span>
</li>
);
})}
</ul>
</div>
);
}

Requirements

DependencyPurpose
lucide-reactIcon components (FileText, Shield, Zap, etc.)
usePricingFeaturesSource of truth for feature text per plan
@/lib/constantsPaymentPlan enum