Redesign landing page, update pricing plans

- Epic landing page with animated gradient mesh background, bento grid features,
  count-up stats, animated code block, how-it-works section, and columned footer
- New pricing: Pro (9), Max (9, highlighted), Unlimited (9) — no free tier
- Updated seed script with new plans (removes free/enterprise)
- Updated standalone /pricing page to match
- All mobile-first and responsive
This commit is contained in:
Zebratic committed 2026-03-14 10:03:27 +00:00
1 parent c34a1a7a78
commit 79d0cfe0a0
6 files changed
+633 -461

No files matched your search

+27 -23
View File
@@ -25,43 +25,47 @@ async function main() {
try {
const now = new Date();
// Remove legacy free plan
await db.collection("subscription_plans").deleteOne({ name: "free" });
await db.collection("subscription_plans").deleteOne({ name: "enterprise" });
const plans = [
{
name: "free",
displayName: "Free",
description: "Get started with basic access",
monthlyPriceCents: 0,
dailyRequestLimit: 100,
dailyTokenLimit: 100000,
requestLimitPerMonth: 3000,
tokenLimitPerMonth: 3000000,
maxApiKeys: 2,
sortOrder: 0,
isPublic: true,
},
{
name: "pro",
displayName: "Pro",
description: "For developers and small teams",
monthlyPriceCents: 2900,
dailyRequestLimit: 5000,
dailyTokenLimit: 2000000,
requestLimitPerMonth: 150000,
tokenLimitPerMonth: 60000000,
maxApiKeys: 10,
monthlyPriceCents: 1900,
dailyRequestLimit: null,
dailyTokenLimit: null,
requestLimitPerMonth: 50000,
tokenLimitPerMonth: 10000000,
maxApiKeys: 5,
sortOrder: 0,
isPublic: true,
},
{
name: "max",
displayName: "Max",
description: "For teams shipping to production",
monthlyPriceCents: 4900,
dailyRequestLimit: null,
dailyTokenLimit: null,
requestLimitPerMonth: 200000,
tokenLimitPerMonth: 50000000,
maxApiKeys: 20,
sortOrder: 1,
isPublic: true,
},
{
name: "enterprise",
displayName: "Enterprise",
description: "Unlimited access for large teams",
name: "unlimited",
displayName: "Unlimited",
description: "No limits, full control",
monthlyPriceCents: 9900,
dailyRequestLimit: null,
dailyTokenLimit: null,
requestLimitPerMonth: null,
tokenLimitPerMonth: null,
maxApiKeys: 50,
maxApiKeys: 100,
sortOrder: 2,
isPublic: true,
},
+26
View File
@@ -67,6 +67,32 @@
font-family: "Roboto", system-ui, sans-serif;
}
/* Landing page animations */
@keyframes mesh-1 {
0%, 100% { transform: translate(0, 0) scale(1); }
33% { transform: translate(80px, -50px) scale(1.1); }
66% { transform: translate(-40px, 60px) scale(0.95); }
}
@keyframes mesh-2 {
0%, 100% { transform: translate(0, 0) scale(1); }
33% { transform: translate(-60px, 40px) scale(1.05); }
66% { transform: translate(50px, -30px) scale(0.9); }
}
@keyframes mesh-3 {
0%, 100% { transform: translate(0, 0) scale(1); }
33% { transform: translate(40px, 30px) scale(0.95); }
66% { transform: translate(-70px, -40px) scale(1.1); }
}
@keyframes fade-in {
from { opacity: 0; transform: translateY(4px); }
to { opacity: 1; transform: translateY(0); }
}
.animate-mesh-1 { animation: mesh-1 20s ease-in-out infinite; }
.animate-mesh-2 { animation: mesh-2 25s ease-in-out infinite; }
.animate-mesh-3 { animation: mesh-3 22s ease-in-out infinite; }
.animate-fade-in { animation: fade-in 0.4s ease-out both; }
/* Safe area insets for PWA */
@supports (padding: env(safe-area-inset-top)) {
.phone-ui {
+321 -289
View File
@@ -2,15 +2,15 @@ import Link from "next/link";
import { redirect } from "next/navigation";
import {
ArrowRight,
Sparkles,
Zap,
Shield,
BarChart3,
Code2,
Globe,
Menu,
Check,
Key,
Gauge,
Layers,
} from "lucide-react";
import { getSession } from "@/lib/auth-helpers";
import { Button } from "@/components/ui/button";
@@ -22,357 +22,389 @@ import {
PerplexityLogo,
ElevenLabsLogo,
} from "@/components/provider-logos";
import { CountUp } from "@/components/landing/counter";
import { AnimatedCodeBlock } from "@/components/landing/code-block";
const providers = [
{ name: "OpenAI", models: "GPT-4.1, GPT-4o, o3, o4-mini", Logo: OpenAILogo },
{ name: "Anthropic", models: "Claude Opus, Sonnet, Haiku", Logo: AnthropicLogo },
{ name: "xAI", models: "Grok 3, Grok 3 Mini", Logo: XAILogo },
{ name: "DeepSeek", models: "V3, R1", Logo: DeepSeekLogo },
{ name: "Perplexity", models: "Sonar Pro, Sonar", Logo: PerplexityLogo },
{ name: "ElevenLabs", models: "Text-to-Speech, Voice AI", Logo: ElevenLabsLogo },
{ name: "OpenAI", Logo: OpenAILogo },
{ name: "Anthropic", Logo: AnthropicLogo },
{ name: "xAI", Logo: XAILogo },
{ name: "DeepSeek", Logo: DeepSeekLogo },
{ name: "Perplexity", Logo: PerplexityLogo },
{ name: "ElevenLabs", Logo: ElevenLabsLogo },
];
const highlights = [
const features = [
{
icon: Globe,
title: "Multi-Provider",
desc: "OpenAI, Anthropic, Grok, DeepSeek, Perplexity — all through one endpoint.",
title: "Multi-Provider Access",
desc: "OpenAI, Anthropic, Grok, DeepSeek, Perplexity & ElevenLabs — all through one endpoint.",
span: "sm:col-span-2",
},
{
icon: Zap,
title: "Smart Routing & Fallback",
desc: "Automatic failover between providers. Zero downtime, zero manual switching.",
span: "",
},
{
icon: BarChart3,
title: "Usage Analytics",
desc: "Track tokens, costs, and latency across every provider in real time.",
title: "Usage Analytics & Cost Tracking",
desc: "Track tokens, costs, and latency across every provider and model in real time.",
span: "",
},
{
icon: Key,
title: "API Key Management",
desc: "Scoped keys with labels, per-key cost caps, and environment controls.",
span: "",
},
{
icon: Shield,
title: "Rate Limiting",
title: "Rate Limiting & Quotas",
desc: "Per-key and per-user rate limits to protect your budget and infrastructure.",
span: "",
},
{
icon: Code2,
title: "Drop-in Compatible",
desc: "Works with any OpenAI SDK. Change the base URL and you're done.",
},
{
icon: Zap,
title: "Smart Routing",
desc: "Automatic provider fallbacks. No downtime, no manual switching.",
title: "OpenAI SDK Compatible",
desc: "Works with any OpenAI SDK or HTTP client. Change the base URL and you're done.",
span: "sm:col-span-2",
},
];
const plans = [
{
name: "Free",
price: "$0",
period: "forever",
desc: "Get started with generous limits",
features: [
"1,000 requests/day",
"All providers & models",
"1 API key",
"Basic analytics",
"Community support",
],
cta: "Get Started Free",
href: "/register",
highlighted: false,
},
{
name: "Pro",
price: "$9.99",
price: "$19",
period: "/month",
desc: "For developers and small teams",
features: [
"50,000 requests/day",
"All providers & models",
"10 API keys",
"50,000 requests/month",
"10M tokens/month",
"5 API keys",
"All standard models",
"Usage analytics",
"Email support",
],
cta: "Get Started",
highlighted: false,
},
{
name: "Max",
price: "$49",
period: "/month",
desc: "For teams shipping to production",
badge: "Most Popular",
features: [
"200,000 requests/month",
"50M tokens/month",
"20 API keys",
"All models incl. premium",
"Priority routing & auto-fallback",
"Advanced analytics",
"Priority support",
"Custom rate limits",
],
cta: "Start Pro Trial",
href: "/register",
cta: "Get Started",
highlighted: true,
},
{
name: "Unlimited",
price: "$49.99",
price: "$99",
period: "/month",
desc: "For production workloads",
desc: "No limits, full control",
features: [
"Unlimited requests",
"All providers & models",
"Unlimited API keys",
"Full analytics & exports",
"Unlimited tokens",
"100 API keys",
"All models, all providers",
"Priority routing & smart fallback",
"Real-time analytics dashboard",
"Dedicated support",
"Custom rate limits",
"GDPR log controls",
"Custom model aliases",
"Webhook notifications",
],
cta: "Go Unlimited",
href: "/register",
cta: "Get Started",
highlighted: false,
},
];
const steps = [
{ num: "1", title: "Sign up & get your API key", desc: "Create an account and generate your first key in seconds." },
{ num: "2", title: "Use it like OpenAI's API", desc: "Point any OpenAI SDK at our endpoint. Same interface, more models." },
{ num: "3", title: "We route to the best provider", desc: "Automatic model resolution, failover, and load balancing." },
];
export default async function Home() {
const session = await getSession();
if (session?.user) redirect("/chat");
return (
<main className="relative min-h-screen overflow-x-hidden bg-background text-foreground">
{/* Background glow */}
<div className="pointer-events-none absolute inset-0">
<div className="absolute -left-40 -top-20 h-[500px] w-[500px] rounded-full bg-blue-500/[0.06] blur-[150px]" />
<div className="absolute bottom-0 right-0 h-[400px] w-[400px] rounded-full bg-blue-600/[0.04] blur-[150px]" />
<main className="relative min-h-screen overflow-x-hidden bg-zinc-950 text-foreground">
{/* Animated gradient mesh background */}
<div className="pointer-events-none fixed inset-0 overflow-hidden">
<div className="animate-mesh-1 absolute -left-1/4 -top-1/4 h-[800px] w-[800px] rounded-full bg-blue-600/[0.07] blur-[120px]" />
<div className="animate-mesh-2 absolute -right-1/4 top-1/3 h-[600px] w-[600px] rounded-full bg-purple-600/[0.05] blur-[120px]" />
<div className="animate-mesh-3 absolute bottom-0 left-1/3 h-[700px] w-[700px] rounded-full bg-indigo-600/[0.06] blur-[120px]" />
</div>
<div className="relative mx-auto flex w-full max-w-5xl flex-col px-4 pb-16 pt-4 sm:px-6 md:px-8">
{/* Nav */}
<nav className="mb-12 flex items-center justify-between rounded-2xl border border-white/[0.06] bg-white/[0.02] px-4 py-3 backdrop-blur-xl sm:mb-20">
<Link href="/" className="flex items-center gap-2 text-sm font-medium tracking-wide">
<Sparkles className="h-4 w-4 text-blue-400" />
LLM Proxy
</Link>
{/* Desktop nav */}
<div className="hidden items-center gap-1.5 sm:flex">
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/docs">Docs</Link>
</Button>
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/pricing">Pricing</Link>
</Button>
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/login">Login</Link>
</Button>
<Button asChild size="sm" className="bg-blue-500 text-white hover:bg-blue-400">
<Link href="/register">Get Started</Link>
</Button>
</div>
{/* Mobile nav */}
<div className="flex items-center gap-2 sm:hidden">
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/login">Login</Link>
</Button>
<Button asChild size="sm" className="bg-blue-500 text-white hover:bg-blue-400">
<Link href="/register">Sign Up</Link>
</Button>
<div className="relative">
{/* Sticky Nav */}
<nav className="sticky top-0 z-50 border-b border-white/[0.04] bg-zinc-950/80 backdrop-blur-xl">
<div className="mx-auto flex max-w-6xl items-center justify-between px-4 py-3 sm:px-6">
<Link href="/" className="flex items-center gap-2 text-sm font-semibold tracking-wide">
<Layers className="h-5 w-5 text-blue-400" />
<span>LLM Proxy</span>
</Link>
<div className="hidden items-center gap-6 sm:flex">
<Link href="#features" className="text-sm text-muted-foreground transition-colors hover:text-foreground">Features</Link>
<Link href="#pricing" className="text-sm text-muted-foreground transition-colors hover:text-foreground">Pricing</Link>
<Link href="/docs" className="text-sm text-muted-foreground transition-colors hover:text-foreground">Docs</Link>
</div>
<div className="flex items-center gap-2">
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/login">Login</Link>
</Button>
<Button asChild size="sm" className="bg-gradient-to-r from-blue-500 to-purple-500 text-white hover:from-blue-400 hover:to-purple-400">
<Link href="/register">Sign Up</Link>
</Button>
</div>
</div>
</nav>
{/* Hero */}
<section className="mb-16 text-center sm:mb-24">
<div className="mx-auto mb-4 inline-flex items-center gap-2 rounded-full border border-blue-400/20 bg-blue-500/10 px-3.5 py-1.5 text-xs font-medium text-blue-300">
<span className="h-1.5 w-1.5 rounded-full bg-blue-400" />
OpenAI-compatible — works with any SDK
</div>
<h1 className="mx-auto max-w-3xl text-3xl font-bold leading-[1.1] tracking-tight sm:text-5xl md:text-6xl">
One API.
<br />
<span className="text-blue-400">Every Model.</span>
</h1>
<p className="mx-auto mt-4 max-w-xl text-sm text-muted-foreground sm:mt-5 sm:text-base md:text-lg">
Access OpenAI, Anthropic, xAI, DeepSeek, and Perplexity through a single API key.
Drop-in replacement for any OpenAI SDK.
</p>
<div className="mt-6 flex flex-col items-center gap-3 sm:mt-8 sm:flex-row sm:justify-center">
<Button asChild size="lg" className="w-full bg-blue-500 text-white hover:bg-blue-400 sm:w-auto">
<Link href="/register">
Get Started Free
<ArrowRight className="ml-1.5 h-4 w-4" />
</Link>
</Button>
<Button asChild size="lg" variant="outline" className="w-full border-white/[0.08] bg-white/[0.03] hover:bg-white/[0.06] sm:w-auto">
<Link href="/login">Login</Link>
</Button>
</div>
</section>
{/* Code snippet */}
<section className="mb-16 sm:mb-24">
<div className="overflow-hidden rounded-2xl border border-white/[0.06] bg-white/[0.02]">
<div className="flex items-center gap-2 border-b border-white/[0.06] px-4 py-2.5">
<div className="h-2.5 w-2.5 rounded-full bg-white/10" />
<div className="h-2.5 w-2.5 rounded-full bg-white/10" />
<div className="h-2.5 w-2.5 rounded-full bg-white/10" />
<span className="ml-2 text-xs text-muted-foreground">quickstart.py</span>
<div className="mx-auto max-w-6xl px-4 sm:px-6">
{/* Hero */}
<section className="pb-16 pt-16 text-center sm:pb-24 sm:pt-24 md:pt-32">
{/* Badge */}
<div className="mx-auto mb-6 inline-flex items-center gap-2 rounded-full border border-blue-400/20 bg-blue-500/10 px-4 py-1.5 text-xs font-medium text-blue-300 shadow-[0_0_15px_rgba(59,130,246,0.15)]">
<span className="h-1.5 w-1.5 animate-pulse rounded-full bg-blue-400" />
OpenAI Compatible
</div>
<pre className="overflow-x-auto p-4 text-xs leading-relaxed sm:p-5 sm:text-sm">
<code>
<span className="text-blue-400">from</span>{" "}
<span className="text-foreground/80">openai</span>{" "}
<span className="text-blue-400">import</span>{" "}
<span className="text-foreground/80">OpenAI</span>
{"\n\n"}
<span className="text-foreground/80">client</span>{" "}
<span className="text-muted-foreground">=</span>{" "}
<span className="text-foreground/80">OpenAI</span>
<span className="text-muted-foreground">(</span>
{"\n"}
{" "}
<span className="text-foreground/80">base_url</span>
<span className="text-muted-foreground">=</span>
<span className="text-emerald-400">&quot;https://your-domain.com/v1&quot;</span>
<span className="text-muted-foreground">,</span>
{"\n"}
{" "}
<span className="text-foreground/80">api_key</span>
<span className="text-muted-foreground">=</span>
<span className="text-emerald-400">&quot;your-api-key&quot;</span>
{"\n"}
<span className="text-muted-foreground">)</span>
{"\n\n"}
<span className="text-muted-foreground"># Use any model — same interface</span>
{"\n"}
<span className="text-foreground/80">response</span>{" "}
<span className="text-muted-foreground">=</span>{" "}
<span className="text-foreground/80">client.chat.completions.create</span>
<span className="text-muted-foreground">(</span>
{"\n"}
{" "}
<span className="text-foreground/80">model</span>
<span className="text-muted-foreground">=</span>
<span className="text-emerald-400">&quot;claude-sonnet-4-20250514&quot;</span>
<span className="text-muted-foreground">,</span>
{"\n"}
{" "}
<span className="text-foreground/80">messages</span>
<span className="text-muted-foreground">=</span>
<span className="text-muted-foreground">[&#123;</span>
<span className="text-emerald-400">&quot;role&quot;</span>
<span className="text-muted-foreground">:</span>{" "}
<span className="text-emerald-400">&quot;user&quot;</span>
<span className="text-muted-foreground">,</span>{" "}
<span className="text-emerald-400">&quot;content&quot;</span>
<span className="text-muted-foreground">:</span>{" "}
<span className="text-emerald-400">&quot;Hello!&quot;</span>
<span className="text-muted-foreground">&#125;]</span>
{"\n"}
<span className="text-muted-foreground">)</span>
</code>
</pre>
</div>
</section>
{/* Providers */}
<section className="mb-16 sm:mb-24">
<h2 className="mb-6 text-center text-xs font-medium uppercase tracking-[0.2em] text-muted-foreground sm:mb-8">
Supported Providers
</h2>
<div className="mx-auto grid max-w-3xl grid-cols-2 gap-3 sm:grid-cols-3">
{providers.map((p) => (
<div
key={p.name}
className="flex flex-col items-center gap-2.5 rounded-2xl border border-white/[0.06] bg-white/[0.02] px-3 py-5 transition-colors hover:border-white/[0.12] hover:bg-white/[0.04] sm:gap-3 sm:px-4 sm:py-6"
>
<p.Logo className="h-7 w-7 text-foreground/80 sm:h-8 sm:w-8" />
<div className="text-center">
<p className="text-sm font-medium">{p.name}</p>
<p className="mt-0.5 text-[11px] text-muted-foreground sm:text-xs">{p.models}</p>
</div>
</div>
))}
</div>
</section>
<h1 className="mx-auto max-w-4xl text-4xl font-extrabold leading-[1.08] tracking-tight sm:text-6xl md:text-7xl">
One API Key.{" "}
<span className="bg-gradient-to-r from-blue-400 via-purple-400 to-pink-400 bg-clip-text text-transparent">
Every AI Model.
</span>
</h1>
{/* Features */}
<section className="mb-16 sm:mb-24">
<h2 className="mb-6 text-center text-xl font-semibold sm:mb-8 sm:text-2xl md:text-3xl">Why LLM Proxy</h2>
<div className="grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 sm:gap-4">
{highlights.map((h) => (
<div
key={h.title}
className="rounded-xl border border-white/[0.06] bg-white/[0.02] p-4 sm:p-5"
>
<h.icon className="mb-2.5 h-5 w-5 text-blue-400 sm:mb-3" />
<h3 className="mb-1 text-sm font-semibold sm:mb-1.5">{h.title}</h3>
<p className="text-xs leading-relaxed text-muted-foreground sm:text-sm">{h.desc}</p>
</div>
))}
</div>
</section>
<p className="mx-auto mt-5 max-w-2xl text-base text-muted-foreground sm:mt-6 sm:text-lg md:text-xl">
Access GPT-5, Claude Opus, Grok, DeepSeek, and 100+ models through a single OpenAI-compatible endpoint.
</p>
{/* Pricing */}
<section className="mb-16 sm:mb-24">
<h2 className="mb-2 text-center text-xl font-semibold sm:text-2xl md:text-3xl">Simple Pricing</h2>
<p className="mx-auto mb-8 max-w-md text-center text-sm text-muted-foreground sm:mb-10">
Start free. Scale when you&apos;re ready.
</p>
<div className="mx-auto grid max-w-4xl grid-cols-1 gap-4 sm:grid-cols-3">
{plans.map((plan) => (
<div
key={plan.name}
className={`relative flex flex-col rounded-2xl border p-5 sm:p-6 ${
plan.highlighted
? "border-blue-500/40 bg-blue-500/[0.06]"
: "border-white/[0.06] bg-white/[0.02]"
}`}
>
{plan.highlighted && (
<div className="absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-blue-500 px-3 py-0.5 text-xs font-medium text-white">
Popular
<div className="mt-8 flex flex-col items-center gap-3 sm:mt-10 sm:flex-row sm:justify-center">
<Button asChild size="lg" className="w-full bg-gradient-to-r from-blue-500 to-purple-500 text-white shadow-lg shadow-blue-500/20 hover:from-blue-400 hover:to-purple-400 sm:w-auto sm:px-8">
<Link href="/register">
Get Started
<ArrowRight className="ml-1.5 h-4 w-4" />
</Link>
</Button>
<Button asChild size="lg" variant="outline" className="w-full border-white/[0.1] bg-white/[0.03] hover:bg-white/[0.06] sm:w-auto sm:px-8">
<Link href="/docs">View Docs</Link>
</Button>
</div>
{/* Code block */}
<div className="mx-auto mt-12 max-w-2xl sm:mt-16">
<AnimatedCodeBlock />
</div>
</section>
{/* Stats */}
<section className="pb-16 sm:pb-24">
<div className="grid grid-cols-2 gap-4 sm:grid-cols-4">
{[
{ end: 100, suffix: "+", label: "Models" },
{ end: 6, suffix: "", label: "Providers" },
{ end: 99, suffix: ".9%", label: "Uptime" },
{ end: 100, suffix: "ms", prefix: "<", label: "Overhead" },
].map((stat) => (
<div key={stat.label} className="rounded-2xl border border-white/[0.06] bg-white/[0.02] px-4 py-6 text-center backdrop-blur-sm">
<div className="text-2xl font-bold text-foreground sm:text-3xl">
<CountUp end={stat.end} suffix={stat.suffix} prefix={stat.prefix} />
</div>
)}
<h3 className="text-lg font-semibold">{plan.name}</h3>
<div className="mt-2 flex items-baseline gap-1">
<span className="text-3xl font-bold">{plan.price}</span>
<span className="text-sm text-muted-foreground">{plan.period}</span>
<div className="mt-1 text-xs text-muted-foreground sm:text-sm">{stat.label}</div>
</div>
<p className="mt-2 text-xs text-muted-foreground">{plan.desc}</p>
<ul className="mt-4 flex-1 space-y-2">
{plan.features.map((f) => (
<li key={f} className="flex items-start gap-2 text-xs text-muted-foreground sm:text-sm">
<Check className="mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-blue-400" />
{f}
</li>
))}
</ul>
<Button
asChild
size="lg"
className={`mt-5 w-full ${
plan.highlighted
? "bg-blue-500 text-white hover:bg-blue-400"
: "border border-white/[0.08] bg-white/[0.03] text-foreground hover:bg-white/[0.06]"
}`}
variant={plan.highlighted ? "default" : "outline"}
))}
</div>
</section>
{/* Providers strip */}
<section className="pb-16 sm:pb-24">
<h2 className="mb-6 text-center text-xs font-medium uppercase tracking-[0.2em] text-muted-foreground sm:mb-8">
Supported Providers
</h2>
<div className="flex flex-wrap items-center justify-center gap-6 sm:gap-10">
{providers.map((p) => (
<div key={p.name} className="flex items-center gap-2 text-muted-foreground transition-colors hover:text-foreground">
<p.Logo className="h-6 w-6 sm:h-7 sm:w-7" />
<span className="text-sm font-medium">{p.name}</span>
</div>
))}
</div>
</section>
{/* Features - Bento Grid */}
<section id="features" className="pb-16 sm:pb-24">
<h2 className="mb-3 text-center text-2xl font-bold sm:text-3xl md:text-4xl">
Everything you need
</h2>
<p className="mx-auto mb-10 max-w-lg text-center text-sm text-muted-foreground sm:text-base">
A complete API gateway for all your AI models, with the tools to manage them.
</p>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 sm:gap-4">
{features.map((f) => (
<div
key={f.title}
className={`group rounded-2xl border border-white/[0.06] bg-white/[0.02] p-5 transition-all duration-300 hover:border-white/[0.12] hover:bg-white/[0.04] hover:shadow-lg hover:shadow-blue-500/[0.03] sm:p-6 ${f.span}`}
>
<Link href={plan.href}>{plan.cta}</Link>
</Button>
<div className="mb-3 inline-flex rounded-xl bg-blue-500/10 p-2.5 transition-colors group-hover:bg-blue-500/20">
<f.icon className="h-5 w-5 text-blue-400" />
</div>
<h3 className="mb-1.5 text-sm font-semibold sm:text-base">{f.title}</h3>
<p className="text-xs leading-relaxed text-muted-foreground sm:text-sm">{f.desc}</p>
</div>
))}
</div>
</section>
{/* How It Works */}
<section className="pb-16 sm:pb-24">
<h2 className="mb-3 text-center text-2xl font-bold sm:text-3xl md:text-4xl">
How it works
</h2>
<p className="mx-auto mb-10 max-w-lg text-center text-sm text-muted-foreground sm:text-base">
Get started in under a minute. No config files, no infrastructure.
</p>
<div className="mx-auto grid max-w-3xl grid-cols-1 gap-6 sm:grid-cols-3 sm:gap-4">
{steps.map((step, i) => (
<div key={step.num} className="relative text-center">
{i < steps.length - 1 && (
<div className="absolute left-1/2 top-8 hidden h-px w-full bg-gradient-to-r from-blue-500/30 to-transparent sm:block" />
)}
<div className="relative mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full border border-blue-500/30 bg-blue-500/10 text-lg font-bold text-blue-400">
{step.num}
</div>
<h3 className="mb-2 text-sm font-semibold sm:text-base">{step.title}</h3>
<p className="text-xs text-muted-foreground sm:text-sm">{step.desc}</p>
</div>
))}
</div>
</section>
{/* Pricing */}
<section id="pricing" className="pb-16 sm:pb-24">
<h2 className="mb-3 text-center text-2xl font-bold sm:text-3xl md:text-4xl">
Simple, transparent pricing
</h2>
<p className="mx-auto mb-10 max-w-md text-center text-sm text-muted-foreground sm:text-base">
No hidden fees. No free tier limits to hit. Just pick a plan and build.
</p>
<div className="mx-auto grid max-w-5xl grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
{plans.map((plan) => (
<div
key={plan.name}
className={`relative flex flex-col rounded-2xl border p-6 transition-all duration-300 hover:shadow-xl sm:p-7 ${
plan.highlighted
? "border-blue-500/40 bg-gradient-to-b from-blue-500/[0.08] to-purple-500/[0.04] shadow-lg shadow-blue-500/[0.08] hover:shadow-blue-500/[0.15]"
: "border-white/[0.06] bg-white/[0.02] hover:border-white/[0.12] hover:shadow-white/[0.03]"
}`}
>
{plan.badge && (
<div className="absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-gradient-to-r from-blue-500 to-purple-500 px-4 py-1 text-xs font-semibold text-white shadow-lg shadow-blue-500/30">
{plan.badge}
</div>
)}
<h3 className="text-lg font-semibold">{plan.name}</h3>
<div className="mt-3 flex items-baseline gap-1">
<span className="text-4xl font-bold">{plan.price}</span>
<span className="text-sm text-muted-foreground">{plan.period}</span>
</div>
<p className="mt-2 text-xs text-muted-foreground">{plan.desc}</p>
<ul className="mt-5 flex-1 space-y-2.5">
{plan.features.map((f) => (
<li key={f} className="flex items-start gap-2 text-xs text-muted-foreground sm:text-sm">
<Check className="mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-blue-400" />
{f}
</li>
))}
</ul>
<Button
asChild
size="lg"
className={`mt-6 w-full ${
plan.highlighted
? "bg-gradient-to-r from-blue-500 to-purple-500 text-white shadow-md shadow-blue-500/20 hover:from-blue-400 hover:to-purple-400"
: "border border-white/[0.08] bg-white/[0.03] text-foreground hover:bg-white/[0.06]"
}`}
variant={plan.highlighted ? "default" : "outline"}
>
<Link href="/register">
{plan.cta}
<ArrowRight className="ml-1.5 h-4 w-4" />
</Link>
</Button>
</div>
))}
</div>
</section>
{/* Final CTA */}
<section className="pb-16 sm:pb-24">
<div className="rounded-3xl border border-blue-500/20 bg-gradient-to-r from-blue-500/[0.08] via-purple-500/[0.06] to-pink-500/[0.04] px-6 py-12 text-center sm:px-10 sm:py-16">
<h3 className="text-2xl font-bold sm:text-3xl md:text-4xl">
Ready to simplify your AI stack?
</h3>
<p className="mx-auto mt-4 max-w-lg text-sm text-muted-foreground sm:text-base">
Create an account, grab your API key, and start making requests in under a minute.
</p>
<Button asChild size="lg" className="mt-8 bg-gradient-to-r from-blue-500 to-purple-500 px-10 text-white shadow-lg shadow-blue-500/20 hover:from-blue-400 hover:to-purple-400">
<Link href="/register">
Get Started
<ArrowRight className="ml-1.5 h-4 w-4" />
</Link>
</Button>
</div>
</section>
{/* Footer */}
<footer className="border-t border-white/[0.06] pb-10 pt-10">
<div className="grid grid-cols-2 gap-8 sm:grid-cols-4">
<div>
<div className="mb-4 flex items-center gap-2 text-sm font-semibold">
<Layers className="h-4 w-4 text-blue-400" />
LLM Proxy
</div>
<p className="text-xs text-muted-foreground">One API for every AI model.</p>
</div>
))}
</div>
</section>
{/* CTA */}
<section className="rounded-2xl border border-blue-500/20 bg-gradient-to-r from-blue-500/[0.08] to-blue-600/[0.03] px-6 py-10 text-center sm:px-8 sm:py-12">
<h3 className="text-xl font-semibold sm:text-2xl md:text-3xl">Ready to simplify your AI stack?</h3>
<p className="mx-auto mt-3 max-w-lg text-sm text-muted-foreground sm:text-base">
Create an account, grab your API key, and start making requests in under a minute.
</p>
<div className="mt-6 flex flex-col items-center gap-3 sm:flex-row sm:justify-center">
<Button asChild size="lg" className="w-full bg-blue-500 text-white hover:bg-blue-400 sm:w-auto">
<Link href="/register">Get Started Free</Link>
</Button>
<Button asChild size="lg" variant="ghost" className="w-full text-muted-foreground hover:text-foreground sm:w-auto">
<Link href="/pricing">View Plans</Link>
</Button>
</div>
</section>
{/* Footer */}
<footer className="mt-12 flex flex-col items-center gap-3 text-xs text-muted-foreground sm:mt-16 sm:flex-row sm:justify-between">
<span>LLM Proxy</span>
<div className="flex gap-5">
<Link href="/docs" className="hover:text-foreground">Docs</Link>
<Link href="/pricing" className="hover:text-foreground">Pricing</Link>
<Link href="/login" className="hover:text-foreground">Login</Link>
</div>
</footer>
<div>
<h4 className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground">Product</h4>
<div className="flex flex-col gap-2">
<Link href="#features" className="text-sm text-muted-foreground hover:text-foreground">Features</Link>
<Link href="#pricing" className="text-sm text-muted-foreground hover:text-foreground">Pricing</Link>
<Link href="/docs" className="text-sm text-muted-foreground hover:text-foreground">API Reference</Link>
</div>
</div>
<div>
<h4 className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground">Developers</h4>
<div className="flex flex-col gap-2">
<Link href="/docs" className="text-sm text-muted-foreground hover:text-foreground">Documentation</Link>
<Link href="/register" className="text-sm text-muted-foreground hover:text-foreground">Get API Key</Link>
</div>
</div>
<div>
<h4 className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground">Company</h4>
<div className="flex flex-col gap-2">
<Link href="/login" className="text-sm text-muted-foreground hover:text-foreground">Login</Link>
<Link href="/register" className="text-sm text-muted-foreground hover:text-foreground">Sign Up</Link>
</div>
</div>
</div>
<div className="mt-8 border-t border-white/[0.06] pt-6 text-center text-xs text-muted-foreground">
© {new Date().getFullYear()} LLM Proxy. All rights reserved.
</div>
</footer>
</div>
</div>
</main>
);
+141 -149
View File
@@ -1,181 +1,173 @@
"use client";
import Link from "next/link";
import { useEffect, useState } from "react";
import { ArrowRight, Check, Sparkles } from "lucide-react";
import { ArrowRight, Check, Layers } from "lucide-react";
import { Button } from "@/components/ui/button";
interface Plan {
id: string;
name: string;
displayName: string;
description?: string;
monthlyPriceCents: number;
requestLimitPerMonth?: number | null;
tokenLimitPerMonth?: number | null;
dailyRequestLimit?: number | null;
dailyTokenLimit?: number | null;
maxApiKeys: number;
features?: Record<string, unknown>;
}
function formatNumber(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(n % 1_000_000 === 0 ? 0 : 1)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(n % 1_000 === 0 ? 0 : 1)}K`;
return n.toLocaleString();
}
function formatPrice(cents: number): string {
if (cents === 0) return "Free";
const dollars = cents / 100;
return `$${dollars % 1 === 0 ? dollars.toFixed(0) : dollars.toFixed(2)}`;
}
const plans = [
{
name: "Pro",
price: "$19",
period: "/month",
desc: "For developers and small teams",
features: [
"50,000 requests/month",
"10M tokens/month",
"5 API keys",
"All standard models (GPT-4.1, Claude Sonnet, DeepSeek, etc.)",
"Usage analytics",
"Email support",
],
highlighted: false,
},
{
name: "Max",
price: "$49",
period: "/month",
desc: "For teams shipping to production",
badge: "Most Popular",
features: [
"200,000 requests/month",
"50M tokens/month",
"20 API keys",
"All models including premium (GPT-5, Claude Opus, o3)",
"Priority routing & auto-fallback",
"Advanced analytics",
"Priority support",
],
highlighted: true,
},
{
name: "Unlimited",
price: "$99",
period: "/month",
desc: "No limits, full control",
features: [
"Unlimited requests",
"Unlimited tokens",
"100 API keys",
"All models, all providers",
"Priority routing & smart fallback",
"Real-time analytics dashboard",
"Dedicated support",
"Custom model aliases",
"Webhook notifications",
],
highlighted: false,
},
];
export default function PricingPage() {
const [plans, setPlans] = useState<Plan[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetch("/api/plans")
.then((r) => r.json())
.then((d) => setPlans(d.data ?? []))
.catch(() => {})
.finally(() => setLoading(false));
}, []);
return (
<main className="relative min-h-screen overflow-hidden bg-background text-foreground">
<div className="pointer-events-none absolute inset-0">
<div className="absolute -left-60 -top-20 h-[600px] w-[600px] rounded-full bg-blue-500/[0.06] blur-[150px]" />
<div className="absolute bottom-0 right-0 h-[500px] w-[500px] rounded-full bg-blue-600/[0.04] blur-[150px]" />
<main className="relative min-h-screen overflow-hidden bg-zinc-950 text-foreground">
<div className="pointer-events-none fixed inset-0 overflow-hidden">
<div className="animate-mesh-1 absolute -left-1/4 -top-1/4 h-[800px] w-[800px] rounded-full bg-blue-600/[0.07] blur-[120px]" />
<div className="animate-mesh-2 absolute -right-1/4 top-1/3 h-[600px] w-[600px] rounded-full bg-purple-600/[0.05] blur-[120px]" />
</div>
<div className="relative mx-auto flex w-full max-w-5xl flex-col px-5 pb-20 pt-6 sm:px-8">
<div className="relative">
{/* Nav */}
<nav className="mb-16 flex items-center justify-between rounded-2xl border border-white/[0.06] bg-white/[0.02] px-5 py-3 backdrop-blur-xl">
<Link href="/" className="flex items-center gap-2 text-sm font-medium tracking-wide">
<Sparkles className="h-4 w-4 text-blue-400" />
LLM Proxy
</Link>
<div className="flex items-center gap-1.5">
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/docs">Docs</Link>
</Button>
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/pricing">Pricing</Link>
</Button>
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/login">Login</Link>
</Button>
<Button asChild size="sm" className="bg-blue-500 text-white hover:bg-blue-400">
<Link href="/register">Get Started</Link>
</Button>
<nav className="sticky top-0 z-50 border-b border-white/[0.04] bg-zinc-950/80 backdrop-blur-xl">
<div className="mx-auto flex max-w-6xl items-center justify-between px-4 py-3 sm:px-6">
<Link href="/" className="flex items-center gap-2 text-sm font-semibold tracking-wide">
<Layers className="h-5 w-5 text-blue-400" />
<span>LLM Proxy</span>
</Link>
<div className="flex items-center gap-2">
<Button asChild variant="ghost" size="sm" className="text-muted-foreground hover:text-foreground">
<Link href="/login">Login</Link>
</Button>
<Button asChild size="sm" className="bg-gradient-to-r from-blue-500 to-purple-500 text-white hover:from-blue-400 hover:to-purple-400">
<Link href="/register">Sign Up</Link>
</Button>
</div>
</div>
</nav>
{/* Header */}
<section className="mb-12 text-center">
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl md:text-5xl">Plans</h1>
<p className="mx-auto mt-3 max-w-lg text-muted-foreground">
Choose a plan that fits your usage. Upgrade or downgrade anytime.
</p>
</section>
<div className="mx-auto max-w-6xl px-4 sm:px-6">
{/* Header */}
<section className="pb-12 pt-16 text-center sm:pt-20">
<h1 className="text-3xl font-bold tracking-tight sm:text-4xl md:text-5xl">
Simple, transparent{" "}
<span className="bg-gradient-to-r from-blue-400 via-purple-400 to-pink-400 bg-clip-text text-transparent">
pricing
</span>
</h1>
<p className="mx-auto mt-4 max-w-lg text-muted-foreground">
No hidden fees. No free tier limits to hit. Pick a plan and start building.
</p>
</section>
{/* Plans grid */}
{loading ? (
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{[1, 2, 3].map((i) => (
<div
key={i}
className="h-72 animate-pulse rounded-2xl border border-white/[0.06] bg-white/[0.02]"
/>
))}
</div>
) : plans.length === 0 ? (
<p className="text-center text-muted-foreground">No plans available right now.</p>
) : (
<div
className={`grid gap-4 ${
plans.length === 1
? "max-w-sm mx-auto"
: plans.length === 2
? "sm:grid-cols-2 max-w-2xl mx-auto"
: plans.length === 3
? "sm:grid-cols-2 lg:grid-cols-3"
: plans.length === 4
? "sm:grid-cols-2 lg:grid-cols-4"
: "sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
}`}
>
{plans.map((plan) => {
const isFree = plan.monthlyPriceCents === 0;
const limits: string[] = [];
if (plan.requestLimitPerMonth)
limits.push(`${formatNumber(plan.requestLimitPerMonth)} requests/mo`);
if (plan.tokenLimitPerMonth)
limits.push(`${formatNumber(plan.tokenLimitPerMonth)} tokens/mo`);
if (plan.dailyRequestLimit)
limits.push(`${formatNumber(plan.dailyRequestLimit)} requests/day`);
if (plan.dailyTokenLimit)
limits.push(`${formatNumber(plan.dailyTokenLimit)} tokens/day`);
limits.push(`${plan.maxApiKeys} API key${plan.maxApiKeys !== 1 ? "s" : ""}`);
return (
{/* Plans */}
<section className="pb-16 sm:pb-24">
<div className="mx-auto grid max-w-5xl grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
{plans.map((plan) => (
<div
key={plan.id}
className="flex flex-col rounded-2xl border border-white/[0.06] bg-white/[0.02] p-6 transition-colors hover:border-white/[0.12]"
key={plan.name}
className={`relative flex flex-col rounded-2xl border p-6 transition-all duration-300 hover:shadow-xl sm:p-7 ${
plan.highlighted
? "border-blue-500/40 bg-gradient-to-b from-blue-500/[0.08] to-purple-500/[0.04] shadow-lg shadow-blue-500/[0.08] hover:shadow-blue-500/[0.15]"
: "border-white/[0.06] bg-white/[0.02] hover:border-white/[0.12]"
}`}
>
<div className="mb-4">
<h3 className="text-lg font-semibold">{plan.displayName}</h3>
{plan.description && (
<p className="mt-1 text-sm text-muted-foreground">{plan.description}</p>
)}
{plan.badge && (
<div className="absolute -top-3 left-1/2 -translate-x-1/2 rounded-full bg-gradient-to-r from-blue-500 to-purple-500 px-4 py-1 text-xs font-semibold text-white shadow-lg shadow-blue-500/30">
{plan.badge}
</div>
)}
<h3 className="text-lg font-semibold">{plan.name}</h3>
<div className="mt-3 flex items-baseline gap-1">
<span className="text-4xl font-bold">{plan.price}</span>
<span className="text-sm text-muted-foreground">{plan.period}</span>
</div>
<div className="mb-5">
<span className="text-3xl font-bold">{formatPrice(plan.monthlyPriceCents)}</span>
{!isFree && <span className="ml-1 text-sm text-muted-foreground">/month</span>}
</div>
<ul className="mb-6 flex-1 space-y-2.5">
{limits.map((l) => (
<li key={l} className="flex items-start gap-2 text-sm text-muted-foreground">
<Check className="mt-0.5 h-3.5 w-3.5 shrink-0 text-blue-400" />
{l}
<p className="mt-2 text-xs text-muted-foreground">{plan.desc}</p>
<ul className="mt-5 flex-1 space-y-2.5">
{plan.features.map((f) => (
<li key={f} className="flex items-start gap-2 text-sm text-muted-foreground">
<Check className="mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-blue-400" />
{f}
</li>
))}
</ul>
<Button
asChild
className={
isFree
? "border-white/[0.08] bg-white/[0.04] text-foreground hover:bg-white/[0.08]"
: "bg-blue-500 text-white hover:bg-blue-400"
}
variant={isFree ? "outline" : "default"}
size="lg"
className={`mt-6 w-full ${
plan.highlighted
? "bg-gradient-to-r from-blue-500 to-purple-500 text-white shadow-md shadow-blue-500/20 hover:from-blue-400 hover:to-purple-400"
: "border border-white/[0.08] bg-white/[0.03] text-foreground hover:bg-white/[0.06]"
}`}
variant={plan.highlighted ? "default" : "outline"}
>
<Link href="/register">
{isFree ? "Get Started" : "Subscribe"}
<ArrowRight className="ml-1.5 h-3.5 w-3.5" />
Get Started
<ArrowRight className="ml-1.5 h-4 w-4" />
</Link>
</Button>
</div>
);
})}
</div>
)}
))}
</div>
</section>
{/* Footer */}
<footer className="mt-20 flex items-center justify-between text-xs text-muted-foreground">
<span>LLM Proxy</span>
<div className="flex gap-4">
<Link href="/docs" className="hover:text-foreground">Docs</Link>
<Link href="/pricing" className="hover:text-foreground">Pricing</Link>
<Link href="/" className="hover:text-foreground">Home</Link>
</div>
</footer>
{/* FAQ-like CTA */}
<section className="pb-16 sm:pb-24">
<div className="rounded-3xl border border-blue-500/20 bg-gradient-to-r from-blue-500/[0.08] via-purple-500/[0.06] to-pink-500/[0.04] px-6 py-12 text-center sm:px-10">
<h3 className="text-xl font-bold sm:text-2xl">Need a custom plan?</h3>
<p className="mx-auto mt-3 max-w-lg text-sm text-muted-foreground">
Contact us for volume discounts, custom SLAs, and enterprise features.
</p>
</div>
</section>
{/* Footer */}
<footer className="border-t border-white/[0.06] pb-10 pt-6 text-center text-xs text-muted-foreground">
<div className="flex items-center justify-center gap-4">
<Link href="/" className="hover:text-foreground">Home</Link>
<Link href="/docs" className="hover:text-foreground">Docs</Link>
<Link href="/login" className="hover:text-foreground">Login</Link>
</div>
</footer>
</div>
</div>
</main>
);
+82
View File
@@ -0,0 +1,82 @@
"use client";
import { useEffect, useState } from "react";
const lines = [
{ text: "curl https://llm.xmr.network/v1/chat/completions \\", delay: 0 },
{ text: ' -H "Authorization: Bearer sk-your-key" \\', delay: 600 },
{ text: ' -H "Content-Type: application/json" \\', delay: 1000 },
{ text: " -d '{", delay: 1400 },
{ text: ' "model": "gpt-5",', delay: 1800 },
{ text: ' "messages": [{"role": "user", "content": "Hello!"}]', delay: 2200 },
{ text: " }'", delay: 2600 },
];
export function AnimatedCodeBlock() {
const [visible, setVisible] = useState(0);
useEffect(() => {
const timers = lines.map((l, i) =>
setTimeout(() => setVisible(i + 1), l.delay + 500),
);
return () => timers.forEach(clearTimeout);
}, []);
return (
<div className="overflow-hidden rounded-2xl border border-white/[0.06] bg-zinc-950/80 backdrop-blur-sm">
<div className="flex items-center gap-2 border-b border-white/[0.06] px-4 py-2.5">
<div className="h-2.5 w-2.5 rounded-full bg-red-500/60" />
<div className="h-2.5 w-2.5 rounded-full bg-yellow-500/60" />
<div className="h-2.5 w-2.5 rounded-full bg-green-500/60" />
<span className="ml-2 text-xs text-muted-foreground">terminal</span>
</div>
<pre className="overflow-x-auto p-4 text-xs leading-relaxed sm:p-5 sm:text-sm">
<code>
{lines.slice(0, visible).map((line, i) => (
<div key={i} className="animate-fade-in">
{i === 0 && <span className="text-emerald-400">$ </span>}
{line.text.includes('"model"') ? (
<>
<span className="text-muted-foreground">{" "}</span>
<span className="text-blue-400">&quot;model&quot;</span>
<span className="text-muted-foreground">: </span>
<span className="text-emerald-400">&quot;gpt-5&quot;</span>
<span className="text-muted-foreground">,</span>
</>
) : line.text.includes('"messages"') ? (
<>
<span className="text-muted-foreground">{" "}</span>
<span className="text-blue-400">&quot;messages&quot;</span>
<span className="text-muted-foreground">{': [{"role": "user", "content": "Hello!"}]'}</span>
</>
) : line.text.includes("Authorization") ? (
<>
<span className="text-muted-foreground">{" -H "}</span>
<span className="text-amber-400">&quot;Authorization: Bearer sk-your-key&quot;</span>
<span className="text-muted-foreground"> \</span>
</>
) : line.text.includes("Content-Type") ? (
<>
<span className="text-muted-foreground">{" -H "}</span>
<span className="text-amber-400">&quot;Content-Type: application/json&quot;</span>
<span className="text-muted-foreground"> \</span>
</>
) : line.text.startsWith("curl") ? (
<>
<span className="text-purple-400">curl </span>
<span className="text-foreground/80">https://llm.xmr.network/v1/chat/completions</span>
<span className="text-muted-foreground"> \</span>
</>
) : (
<span className="text-muted-foreground">{line.text}</span>
)}
</div>
))}
{visible < lines.length && (
<span className="inline-block h-4 w-1.5 animate-pulse bg-emerald-400" />
)}
</code>
</pre>
</div>
);
}
+36
View File
@@ -0,0 +1,36 @@
"use client";
import { useEffect, useRef, useState } from "react";
export function CountUp({ end, suffix = "", prefix = "", duration = 2000 }: { end: number; suffix?: string; prefix?: string; duration?: number }) {
const [value, setValue] = useState(0);
const ref = useRef<HTMLSpanElement>(null);
const started = useRef(false);
useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => {
if (entry.isIntersecting && !started.current) {
started.current = true;
const start = performance.now();
const step = (now: number) => {
const progress = Math.min((now - start) / duration, 1);
const eased = 1 - Math.pow(1 - progress, 3);
setValue(Math.floor(eased * end));
if (progress < 1) requestAnimationFrame(step);
};
requestAnimationFrame(step);
}
},
{ threshold: 0.3 },
);
if (ref.current) observer.observe(ref.current);
return () => observer.disconnect();
}, [end, duration]);
return (
<span ref={ref}>
{prefix}{value}{suffix}
</span>
);
}