Loading...
Loading...
> Let users try your product before they buy with time-limited trials.
A free trial lets potential customers use your product for a limited time before paying. It's like test-driving a car before buying it. When the trial period ends, users either pay to continue or lose access to premium features. Fabrk's trial system integrates with Stripe so the conversion to paid happens automatically.
DESC: Configure trial settings in src/config.js
1// src/config.js23export const config = {4 features: {5 // Enable/disable trial system6 trialPeriod: true,78 // Number of days for free trial9 trialDays: 14,1011 // Require credit card to start trial?12 // true: Card collected at signup, charged when trial ends13 // false: No card needed, user prompted to pay at trial end14 trialRequiresCard: false,15 },16};
Use these helpers to check trial status
1import {2 isOnTrial,3 getTrialDaysRemaining,4 hasTrialExpired,5 hasUsedTrial6} from "@/lib/trial";78// Check if user is currently on trial9const onTrial = isOnTrial(user.trialEndsAt);1011// Get days remaining (0 if expired)12const daysLeft = getTrialDaysRemaining(user.trialEndsAt);1314// Check if trial has expired15const expired = hasTrialExpired(user.trialEndsAt);1617// Check if user already used their trial (prevents abuse)18const usedTrial = hasUsedTrial(user);
Block access when trial expires
1// In your API route2import { auth } from "@/lib/auth";3import { hasTrialExpired } from "@/lib/trial";45export async function GET() {6 const session = await auth();78 if (!session?.user) {9 return NextResponse.json({ error: "Unauthorized" }, { status: 401 });10 }1112 // Check if user has active subscription OR valid trial13 const user = await prisma.user.findUnique({14 where: { id: session.user.id },15 select: { tier: true, trialEndsAt: true },16 });1718 const hasAccess =19 user.tier !== "free" || // Paid user20 (user.trialEndsAt && !hasTrialExpired(user.trialEndsAt)); // Valid trial2122 if (!hasAccess) {23 return NextResponse.json(24 { error: "Please subscribe to access this feature" },25 { status: 403 }26 );27 }2829 // User has access - continue with premium feature30 return NextResponse.json({ data: "..." });31}
Add the banner to your dashboard layout
1import { TrialBanner } from "@/components/billing/trial-banner";23export default function DashboardLayout({ children }) {4 return (5 <div>6 <TrialBanner />7 <main>{children}</main>8 </div>9 );10}
If you require credit card upfront, Stripe handles the trial automatically
1// Create subscription with trial period2const subscription = await stripe.subscriptions.create({3 customer: customerId,4 items: [{ price: priceId }],5 trial_period_days: config.features.trialDays, // e.g., 1467 // Optional: Don't charge if trial ends and card fails8 payment_settings: {9 save_default_payment_method: "on_subscription",10 },11});
User clicks "Start Free Trial" on your pricing page. They create an account (no credit card required by default) and immediately get access to premium features.
While on trial, users see a banner showing how many days are left. This creates gentle urgency without being annoying.
When trial is almost over (last 3 days), the banner becomes more prominent. Users are prompted to subscribe before losing access.
When trial ends, users can no longer access premium features. They see a message encouraging them to subscribe. If you require credit card upfront, Stripe automatically starts charging.
Plenty of time (8+ days)
"You have 12 days left in your trial"
Running low (4-7 days)
"5 days left - Subscribe to keep access"
Urgent (1-3 days)
"Trial ends tomorrow! Subscribe now"
Expired
"Your trial has ended. Subscribe to continue"
No. Fabrk tracks whether a user has already used a trial. Once they've had one, they can only subscribe (no second trial). This prevents abuse.
User data is preserved. They just can't access premium features. If they subscribe later, all their data is still there. This encourages conversion.
It depends on your business. Card-required trials have fewer signups but higher conversion (40-60%). No-card trials get more signups but lower conversion (10-20%). Test both if you're unsure.
Update the user's trialEndsAt field in the database to a future date. You can also do this via Stripe if using their trial system.